diff --git a/.dockerignore b/.dockerignore index 43429aaf41..36531daf77 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,14 +7,14 @@ # stuff under tee-worker/ tee-worker/.dockerignore -tee-worker/bin/*.bin -tee-worker/bin/key.txt -tee-worker/bin/spid.txt -tee-worker/bin/sidechain_db/ -tee-worker/docker/*.yml -tee-worker/docs/ -tee-worker/scripts/ -tee-worker/target/ -tee-worker/tmp/ -tee-worker/*.Dockerfile -tee-worker/Dockerfile +tee-worker/**/bin/*.bin +tee-worker/**/bin/key.txt +tee-worker/**/bin/spid.txt +tee-worker/**/bin/sidechain_db/ +tee-worker/**/docker/*.yml +tee-worker/**/docs/ +tee-worker/**/scripts/ +tee-worker/**/target/ +tee-worker/**/tmp/ +tee-worker/**/*.Dockerfile +tee-worker/**/Dockerfile diff --git a/.github/file-filter.yml b/.github/file-filter.yml index 2f20d6e1ae..db877faf2d 100644 --- a/.github/file-filter.yml +++ b/.github/file-filter.yml @@ -4,7 +4,7 @@ parachain_src: ¶chain_src - 'parachain/node/**' - 'parachain/pallets/**' - - 'primitives/**' + - 'common/**' - 'parachain/runtime/**' - 'parachain/docker/Dockerfile' - 'parachain/Cargo.*' @@ -23,17 +23,19 @@ coverage_src: &coverage_src - '.github/workflows/coverage.yml' identity_src: &identity_src + - 'common/**' + - 'tee-worker/Cargo.toml' + - 'tee-worker/Cargo.lock' - 'tee-worker/identity/**/*.rs' - - 'tee-worker/identity/**/Cargo.toml' - - 'tee-worker/identity/**/Cargo.lock' - 'tee-worker/identity/**/rust-toolchain.toml' - 'tee-worker/identity/build.Dockerfile' - 'tee-worker/identity/enclave-runtime/**' bitacross_src: &bitacross_src + - 'common/**' + - 'tee-worker/Cargo.toml' + - 'tee-worker/Cargo.lock' - 'tee-worker/bitacross/**/*.rs' - - 'tee-worker/bitacross/**/Cargo.toml' - - 'tee-worker/bitacross/**/Cargo.lock' - 'tee-worker/bitacross/**/rust-toolchain.toml' - 'tee-worker/bitacross/build.Dockerfile' - 'tee-worker/bitacross/enclave-runtime/**' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e61b061d6..cb4a49f926 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -175,8 +175,8 @@ jobs: cargo fmt --all -- --check taplo fmt --check - - name: identity-worker fmt check - working-directory: ./tee-worker/identity + - name: tee-worker fmt check + working-directory: ./tee-worker run: | cargo fmt --all -- --check taplo fmt --check @@ -186,12 +186,6 @@ jobs: run: | cargo fmt --all -- --check - - name: bitacross-worker fmt check - working-directory: ./tee-worker/bitacross - run: | - cargo fmt --all -- --check - taplo fmt --check - - name: bitacross-worker enclave-runtime fmt check working-directory: ./tee-worker/bitacross/enclave-runtime run: | @@ -258,12 +252,6 @@ jobs: - set-condition - sequentialise container: "litentry/litentry-tee-dev:latest" - strategy: - matrix: - type: - - identity - - bitacross - name: ${{ matrix.type }} steps: - uses: actions/checkout@v4 @@ -273,15 +261,15 @@ jobs: sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler - name: Cargo test - working-directory: ./tee-worker/${{ matrix.type }} + working-directory: ./tee-worker run: | cargo test --release - - name: Worker common clippy - working-directory: ./tee-worker/${{ matrix.type }} + - name: Check clippy + working-directory: ./tee-worker shell: bash run: | - for d in . enclave-runtime; do + for d in . identity/enclave-runtime bitacross/enclave-runtime; do pushd "$d" echo "::group::cargo clippy all" cargo clippy --release -- -D warnings @@ -298,26 +286,21 @@ jobs: done - name: Identity-worker specific clippy - if: matrix.type == 'identity' - working-directory: ./tee-worker/identity + working-directory: ./tee-worker/identity/enclave-runtime shell: bash run: | - for d in . enclave-runtime; do - pushd "$d" - echo "::group::cargo clippy sidechain" - cargo clippy --release --features sidechain -- -D warnings - echo "::endgroup::" - echo "::group::cargo clippy evm" - cargo clippy --release --features evm -- -D warnings - echo "::endgroup::" - echo "::group::cargo clippy sidechain development" - cargo clippy --release --features sidechain,development -- -D warnings - echo "::endgroup::" - echo "::group::cargo clippy evm development" - cargo clippy --release --features evm,development -- -D warnings - echo "::endgroup::" - popd - done + echo "::group::cargo clippy sidechain" + cargo clippy --release --features sidechain -- -D warnings + echo "::endgroup::" + echo "::group::cargo clippy evm" + cargo clippy --release --features evm -- -D warnings + echo "::endgroup::" + echo "::group::cargo clippy sidechain development" + cargo clippy --release --features sidechain,development -- -D warnings + echo "::endgroup::" + echo "::group::cargo clippy evm development" + cargo clippy --release --features evm,development -- -D warnings + echo "::endgroup::" - name: Fail early if: failure() diff --git a/Makefile b/Makefile index 221bdbe5d2..212db558d0 100644 --- a/Makefile +++ b/Makefile @@ -115,16 +115,14 @@ fmt: fmt-cargo fmt-taplo fmt-ts .PHONY: fmt-cargo ## cargo fmt fmt-cargo: @cd parachain && cargo fmt --all - @cd tee-worker/identity && cargo fmt --all + @cd tee-worker && cargo fmt --all @cd tee-worker/identity/enclave-runtime && cargo fmt --all - @cd tee-worker/bitacross && cargo fmt --all @cd tee-worker/bitacross/enclave-runtime && cargo fmt --all .PHONY: fmt-taplo ## taplo fmt fmt-taplo: @cd parachain && RUST_LOG=error taplo fmt - @cd tee-worker/identity && RUST_LOG=error taplo fmt - @cd tee-worker/identity/enclave-runtime && RUST_LOG=error taplo fmt + @cd tee-worker && RUST_LOG=error taplo fmt .PHONY: fmt-ts ## ts fmt fmt-ts: diff --git a/local-setup/worker-log-level-config.toml b/local-setup/worker-log-level-config.toml index 172dae7b66..5a6480dd9e 100644 --- a/local-setup/worker-log-level-config.toml +++ b/local-setup/worker-log-level-config.toml @@ -1,14 +1,14 @@ [litentry-worker] RUST_LOG="info" litentry_worker="debug" -ws="warn" +ws="info" sp_io="error" substrate_api_client="warn" itc_parentchain_light_client="info" jsonrpsee_ws_client="warn" jsonrpsee_ws_server="warn" enclave_runtime="debug" -ita_stf="debug" +id_ita_stf="debug" its_rpc_handler="warn" itc_rpc_client="warn" its_consensus_common="debug" @@ -16,7 +16,8 @@ its_state="warn" its_consensus_aura="warn" "aura*"="warn" its_consensus_slots="warn" -itc_direct_rpc_server="debug" +id_itc_direct_rpc_server="debug" +bc_itc_direct_rpc_server="debug" itp_attestation_handler="debug" http_req="debug" lc_mock_server="warn" @@ -26,17 +27,21 @@ lc_identity_verification="debug" lc_stf_task_receiver="debug" lc_stf_task_sender="debug" lc_data_providers="debug" -itp_top_pool="debug" -itc_parentchain_indirect_calls_executor="debug" -itc_direct_rpc_client="debug" -itp_top_pool_author="debug" +id_itp_top_pool="debug" +bc_itp_top_pool="debug" +id_itc_parentchain_indirect_calls_executor="debug" +bc_itc_parentchain_indirect_calls_executor="debug" +id_itc_direct_rpc_client="debug" +bc_itc_direct_rpc_client="debug" +id_itp_top_pool_author="debug" +bc_itp_top_pool_author="debug" bc_musig2_runner="debug" bc_musig2_ceremony="debug" bc_task_receiver="debug" [litentry-cli] RUST_LOG="debug" -ws="warn" +ws="info" sp_io="warn" substrate_api_client="warn" enclave="debug" diff --git a/tee-worker/bitacross/.taplo.toml b/tee-worker/.taplo.toml similarity index 100% rename from tee-worker/bitacross/.taplo.toml rename to tee-worker/.taplo.toml diff --git a/tee-worker/identity/Cargo.lock b/tee-worker/Cargo.lock similarity index 87% rename from tee-worker/identity/Cargo.lock rename to tee-worker/Cargo.lock index 3f7693cab8..10c958bc63 100644 --- a/tee-worker/identity/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", "log 0.4.20", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", "bitvec", @@ -39,7 +39,7 @@ dependencies = [ "scale-decode 0.8.0", "scale-encode", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sp-application-crypto", "sp-core", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "frame-system", "impl-serde", @@ -59,7 +59,7 @@ dependencies = [ "parity-scale-codec", "primitive-types", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sp-application-crypto", "sp-core", @@ -133,7 +133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.10", - "once_cell 1.18.0", + "once_cell 1.19.0", "version_check", ] @@ -145,7 +145,7 @@ checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if 1.0.0", "getrandom 0.2.10", - "once_cell 1.18.0", + "once_cell 1.19.0", "version_check", ] @@ -211,9 +211,9 @@ checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "array-bytes" -version = "6.1.0" +version = "6.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" +checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" [[package]] name = "arrayref" @@ -250,7 +250,7 @@ checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -356,9 +356,9 @@ checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -367,444 +367,1024 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] -name = "bech32" -version = "0.10.0-beta" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" - -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +name = "bc-enclave-registry" +version = "0.1.0" dependencies = [ - "serde 1.0.204", + "base64 0.13.1", + "itp-settings", + "itp-sgx-io", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-std 5.0.0", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "binary-merkle-tree" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +name = "bc-ita-parentchain-interface" +version = "0.1.0" dependencies = [ - "hash-db 0.16.0", + "bc-enclave-registry", + "bc-ita-sgx-runtime", + "bc-ita-stf", + "bc-itc-parentchain-indirect-calls-executor", + "bc-itp-stf-executor", + "bc-itp-top-pool-author", + "bc-relayer-registry", + "bc-signer-registry", + "env_logger 0.10.2", + "itc-parentchain-test", + "itp-api-client-types", + "itp-node-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-test", + "itp-types", + "litentry-primitives", "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", + "sp-std 5.0.0", + "substrate-api-client", ] [[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +name = "bc-ita-sgx-runtime" +version = "0.1.0" dependencies = [ - "serde 1.0.204", + "frame-executive", + "frame-support", + "frame-system", + "itp-sgx-runtime-primitives", + "pallet-balances", + "pallet-parentchain", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std 5.0.0", + "sp-version", ] [[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +name = "bc-ita-stf" +version = "0.1.0" dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex 1.9.5", - "rustc-hash", - "shlex", - "syn 1.0.109", + "bc-ita-sgx-runtime", + "frame-support", + "frame-system", + "hex", + "hex-literal", + "itp-hashing", + "itp-node-api", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-storage", + "itp-types", + "itp-utils", + "litentry-macros 0.1.0", + "litentry-primitives", + "log 0.4.20", + "pallet-balances", + "pallet-parentchain", + "pallet-sudo", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-io 7.0.0", + "sp-keyring", + "sp-runtime", + "sp-std 5.0.0", ] [[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - -[[package]] -name = "bitcoin" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5973a027b341b462105675962214dfe3c938ad9afd395d84b28602608bdcec7b" +name = "bc-itc-direct-rpc-client" +version = "0.1.0" dependencies = [ - "bech32", - "bitcoin-internals", - "bitcoin_hashes", - "core2", - "hex-conservative", - "hex_lit", - "secp256k1 0.28.0", + "itp-rpc", + "itp-types", + "itp-utils", + "log 0.4.20", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", + "rustls 0.19.1", + "serde_json 1.0.103", + "sgx_tstd", + "tungstenite 0.14.0", + "tungstenite 0.15.0", + "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", + "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", ] [[package]] -name = "bitcoin-internals" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" - -[[package]] -name = "bitcoin_hashes" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +name = "bc-itc-direct-rpc-server" +version = "0.1.0" dependencies = [ - "bitcoin-internals", - "core2", - "hex-conservative", + "itc-tls-websocket-server", + "itp-rpc", + "itp-types", + "itp-utils", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "log 0.4.20", + "parity-scale-codec", + "serde_json 1.0.103", + "sgx_tstd", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +name = "bc-itc-offchain-worker-executor" +version = "0.1.0" dependencies = [ - "funty", - "radium", - "tap", - "wyz", + "bc-itp-stf-executor", + "bc-itp-top-pool-author", + "itc-parentchain-light-client", + "itp-extrinsics-factory", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +name = "bc-itc-parentchain" +version = "0.1.0" dependencies = [ - "digest 0.10.7", + "bc-itc-parentchain-block-import-dispatcher", + "bc-itc-parentchain-block-importer", + "bc-itc-parentchain-indirect-calls-executor", + "itc-parentchain-light-client", + "itp-types", + "parity-scale-codec", + "sp-runtime", ] [[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +name = "bc-itc-parentchain-block-import-dispatcher" +version = "0.1.0" dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq 0.1.5", + "bc-itc-parentchain-block-importer", + "itp-import-queue", + "log 0.4.20", + "sgx_tstd", + "sgx_types", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "blake2b_simd" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +name = "bc-itc-parentchain-block-importer" +version = "0.1.0" dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "bc-ita-stf", + "bc-itc-parentchain-indirect-calls-executor", + "bc-itp-stf-executor", + "itc-parentchain-light-client", + "itp-enclave-metrics", + "itp-extrinsics-factory", + "itp-ocall-api", + "itp-stf-interface", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +name = "bc-itc-parentchain-indirect-calls-executor" +version = "0.1.0" dependencies = [ - "block-padding", - "byte-tools", - "byteorder 1.4.3", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" + "bc-enclave-registry", + "bc-itp-stf-executor", + "bc-itp-top-pool-author", + "bc-relayer-registry", + "bc-signer-registry", + "binary-merkle-tree", + "bs58", + "env_logger 0.10.2", + "futures 0.3.28", + "futures 0.3.8", + "itc-parentchain-test", + "itp-api-client-types", + "itp-node-api", + "itp-sgx-crypto", + "itp-sgx-runtime-primitives", + "itp-stf-primitives", + "itp-test", + "itp-types", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "bc-itp-enclave-api" +version = "0.1.0" dependencies = [ - "generic-array 0.14.7", + "bc-itp-enclave-api-ffi", + "frame-support", + "hex", + "itp-settings", + "itp-sgx-crypto", + "itp-stf-interface", + "itp-storage", + "itp-types", + "log 0.4.20", + "pallet-teebag", + "parity-scale-codec", + "serde_json 1.0.103", + "sgx_crypto_helper", + "sgx_types", + "sgx_urts", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", ] [[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +name = "bc-itp-enclave-api-ffi" +version = "0.1.0" dependencies = [ - "generic-array 0.14.7", + "sgx_types", ] [[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +name = "bc-itp-stf-executor" +version = "0.1.0" dependencies = [ - "byte-tools", + "bc-itp-top-pool", + "bc-itp-top-pool-author", + "hex", + "itc-parentchain-test", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-stf-state-observer", + "itp-test", + "itp-time-utils", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", ] [[package]] -name = "bounded-collections" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" +name = "bc-itp-top-pool" +version = "0.1.0" dependencies = [ + "bc-itc-direct-rpc-server", + "byteorder 1.4.3", + "derive_more", + "itp-stf-primitives", + "itp-test", + "itp-types", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "linked-hash-map 0.5.2", + "linked-hash-map 0.5.6", + "litentry-primitives", "log 0.4.20", "parity-scale-codec", - "scale-info", - "serde 1.0.204", + "parity-util-mem", + "serde 1.0.193", + "sgx_tstd", + "sp-application-crypto", + "sp-core", + "sp-runtime", ] [[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +name = "bc-itp-top-pool-author" +version = "0.1.0" +dependencies = [ + "bc-itp-top-pool", + "derive_more", + "futures 0.3.28", + "itp-enclave-metrics", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "itp-utils", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "lazy_static", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_crypto_helper", + "sgx_tstd", + "sp-core", + "sp-keyring", + "sp-runtime", +] [[package]] -name = "bstr" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +name = "bc-musig2-ceremony" +version = "0.1.0" dependencies = [ - "memchr 2.6.3", - "serde 1.0.204", + "itp-sgx-crypto", + "k256", + "litentry-primitives", + "log 0.4.20", + "musig2 0.0.8 (git+https://github.com/kziemianek/musig2?branch=master)", + "musig2 0.0.8 (git+https://github.com/kailai-wang/musig2?branch=use-sha2-0.8)", + "parity-scale-codec", + "rand 0.8.5", + "sgx_rand", + "sgx_tstd", + "signature 2.1.0", ] [[package]] -name = "bumpalo" -version = "3.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +name = "bc-musig2-event" +version = "0.1.0" +dependencies = [ + "bc-enclave-registry", + "bc-itc-direct-rpc-client", + "bc-itc-direct-rpc-server", + "bc-musig2-ceremony", + "itp-ocall-api", + "itp-rpc", + "itp-sgx-crypto", + "itp-types", + "itp-utils", + "lc-direct-call", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "rand 0.8.5", + "sgx_rand", + "sgx_tstd", + "sp-core", + "threadpool 1.8.0", + "threadpool 1.8.1", +] [[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +name = "bc-relayer-registry" +version = "0.1.0" +dependencies = [ + "base64 0.13.1", + "itp-settings", + "itp-sgx-io", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-std 5.0.0", + "thiserror 1.0.44", + "thiserror 1.0.9", +] [[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +name = "bc-signer-registry" +version = "0.1.0" +dependencies = [ + "base64 0.13.1", + "itp-settings", + "itp-sgx-io", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-std 5.0.0", + "thiserror 1.0.44", + "thiserror 1.0.9", +] [[package]] -name = "bytemuck" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +name = "bc-task-processor" +version = "0.1.0" +dependencies = [ + "bc-enclave-registry", + "bc-ita-stf", + "bc-itc-direct-rpc-client", + "bc-itc-direct-rpc-server", + "bc-itp-stf-executor", + "bc-musig2-ceremony", + "bc-musig2-event", + "bc-relayer-registry", + "bc-signer-registry", + "bc-task-sender", + "frame-support", + "futures 0.3.8", + "itp-enclave-metrics", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-externalities", + "itp-stf-state-handler", + "lc-direct-call", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_crypto_helper", + "sgx_tstd", + "sp-core", + "thiserror 1.0.44", + "thiserror 1.0.9", + "threadpool 1.8.0", + "threadpool 1.8.1", +] [[package]] -name = "byteorder" -version = "1.3.4" -source = "git+https://github.com/mesalock-linux/byteorder-sgx?tag=sgx_1.1.3#325f392dcd294109eb05f0a3c45e4141514c7784" +name = "bc-task-sender" +version = "0.1.0" dependencies = [ + "futures 0.3.28", + "futures 0.3.8", + "lazy_static", + "litentry-primitives", + "parity-scale-codec", "sgx_tstd", ] [[package]] -name = "byteorder" -version = "1.4.3" +name = "bech32" +version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" [[package]] -name = "bytes" -version = "0.4.12" +name = "beef" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" dependencies = [ - "byteorder 1.4.3", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.193", ] [[package]] -name = "bytes" -version = "1.0.1" -source = "git+https://github.com/integritee-network/bytes-sgx?branch=sgx-experimental#62ed3082be2e23cb9bc8cc7ee9983a523de69292" +name = "binary-merkle-tree" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "sgx_tstd", + "hash-db 0.16.0", + "log 0.4.20", ] [[package]] -name = "bytes" -version = "1.4.0" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde 1.0.193", +] [[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" +name = "bindgen" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "cc", - "libc", - "pkg-config", + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex 1.9.5", + "rustc-hash", + "shlex", + "syn 1.0.109", ] [[package]] -name = "cargo_toml" -version = "0.19.1" +name = "bit-vec" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dc9f7a067415ab5058020f04c60ec7b557084dbec0e021217bbabc7a8d38d14" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitacross-cli" +version = "0.0.1" dependencies = [ - "serde 1.0.204", - "toml 0.8.2", + "base58", + "bc-ita-parentchain-interface", + "bc-ita-stf", + "bc-musig2-ceremony", + "chrono 0.4.26", + "clap 4.1.0", + "env_logger 0.10.2", + "hdrhistogram", + "hex", + "itc-rpc-client", + "itp-node-api", + "itp-rpc", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-types", + "itp-utils", + "lc-direct-call", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "rand 0.8.5", + "rayon", + "regex 1.9.5", + "reqwest", + "serde 1.0.193", + "serde_json 1.0.103", + "sgx_crypto_helper", + "sp-application-crypto", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "substrate-api-client", + "substrate-client-keystore", + "thiserror 1.0.44", + "urlencoding", ] [[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +name = "bitacross-worker" +version = "0.1.0" dependencies = [ - "jobserver", + "anyhow", + "async-trait", + "base58", + "bc-ita-parentchain-interface", + "bc-itc-parentchain", + "bc-itp-enclave-api", + "clap 2.34.0", + "config", + "dirs", + "env_logger 0.10.2", + "frame-support", + "futures 0.3.28", + "hex", + "humantime", + "ipfs-api", + "itc-parentchain-test", + "itc-rest-client", + "itc-rpc-client", + "itp-api-client-types", + "itp-enclave-metrics", + "itp-node-api", + "itp-settings", + "itp-sgx-crypto", + "itp-stf-interface", + "itp-storage", + "itp-time-utils", + "itp-types", + "itp-utils", + "jsonrpsee", + "lazy_static", + "litentry-primitives", + "log 0.4.20", + "mockall", + "parity-scale-codec", + "parking_lot 0.12.1", + "parse_duration", + "prometheus", + "rayon", + "regex 1.9.5", + "scale-info", + "serde 1.0.193", + "serde_derive 1.0.193", + "serde_json 1.0.103", + "sgx_crypto_helper", + "sgx_types", + "sp-consensus-grandpa", + "sp-core", + "sp-keyring", + "sp-runtime", + "substrate-api-client", + "thiserror 1.0.44", + "tokio", + "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "warp", ] [[package]] -name = "cexpr" -version = "0.6.0" +name = "bitcoin" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +checksum = "5973a027b341b462105675962214dfe3c938ad9afd395d84b28602608bdcec7b" dependencies = [ - "nom", + "bech32", + "bitcoin-internals", + "bitcoin_hashes", + "core2", + "hex-conservative", + "hex_lit", + "secp256k1 0.28.0", ] [[package]] -name = "cfg-expr" -version = "0.10.3" +name = "bitcoin-internals" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" dependencies = [ - "smallvec 1.11.0", + "bitcoin-internals", + "core2", + "hex-conservative", ] [[package]] -name = "cfg-if" -version = "0.1.10" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "cfg-if" -version = "1.0.0" +name = "bitflags" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] -name = "chrono" -version = "0.4.11" -source = "git+https://github.com/mesalock-linux/chrono-sgx#f964ae7f5f65bd2c9cd6f44a067e7980afc08ca0" +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ - "num-integer 0.1.41", - "num-traits 0.2.10", - "sgx_tstd", + "funty", + "radium", + "tap", + "wyz", ] [[package]] -name = "chrono" -version = "0.4.38" +name = "blake2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits 0.2.16", - "serde 1.0.204", - "wasm-bindgen", - "windows-targets 0.52.6", + "digest 0.10.7", ] [[package]] -name = "cipher" -version = "0.2.5" +name = "blake2-rfc" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" dependencies = [ - "generic-array 0.14.7", + "arrayvec 0.4.12", + "constant_time_eq 0.1.5", ] [[package]] -name = "clang-sys" -version = "1.6.1" +name = "blake2b_simd" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ - "glob", - "libc", - "libloading", + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", ] [[package]] -name = "clap" -version = "2.34.0" +name = "block-buffer" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", - "yaml-rust 0.3.5", + "block-padding", + "byte-tools", + "byteorder 1.4.3", + "generic-array 0.12.4", ] [[package]] -name = "clap" -version = "4.1.0" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa91278560fc226a5d9d736cc21e485ff9aad47d26b8ffe1f54cba868b684b9f" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "bitflags 1.3.2", - "clap_derive", - "clap_lex", - "is-terminal", - "once_cell 1.18.0", - "strsim 0.10.0", - "termcolor", + "generic-array 0.14.7", ] [[package]] -name = "clap_derive" -version = "4.1.0" +name = "block-buffer" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", + "generic-array 0.14.7", ] [[package]] -name = "clap_lex" -version = "0.3.3" +name = "block-padding" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" dependencies = [ - "os_str_bytes", + "byte-tools", ] [[package]] -name = "common-multipart-rfc7578" -version = "0.3.1" +name = "bounded-collections" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d0a7a42b9c13f2b2a1a7e64b949a19bcb56a49b190076e60261001ceaa5304" +checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" dependencies = [ - "bytes 1.4.0", + "log 0.4.20", + "parity-scale-codec", + "scale-info", + "serde 1.0.193", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bstr" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +dependencies = [ + "memchr 2.6.3", + "serde 1.0.193", +] + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "git+https://github.com/mesalock-linux/byteorder-sgx?tag=sgx_1.1.3#325f392dcd294109eb05f0a3c45e4141514c7784" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder 1.4.3", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bytes" +version = "1.0.1" +source = "git+https://github.com/integritee-network/bytes-sgx?branch=sgx-experimental#62ed3082be2e23cb9bc8cc7ee9983a523de69292" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "cargo_toml" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dc9f7a067415ab5058020f04c60ec7b557084dbec0e021217bbabc7a8d38d14" +dependencies = [ + "serde 1.0.193", + "toml 0.8.2", +] + +[[package]] +name = "cc" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec 1.11.0", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.11" +source = "git+https://github.com/mesalock-linux/chrono-sgx#f964ae7f5f65bd2c9cd6f44a067e7980afc08ca0" +dependencies = [ + "num-integer 0.1.41", + "num-traits 0.2.10", + "sgx_tstd", +] + +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits 0.2.16", + "serde 1.0.193", + "time", + "wasm-bindgen", + "winapi 0.3.9", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", + "yaml-rust 0.3.5", +] + +[[package]] +name = "clap" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa91278560fc226a5d9d736cc21e485ff9aad47d26b8ffe1f54cba868b684b9f" +dependencies = [ + "bitflags 1.3.2", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell 1.19.0", + "strsim 0.10.0", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "clap_lex" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "common-multipart-rfc7578" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d0a7a42b9c13f2b2a1a7e64b949a19bcb56a49b190076e60261001ceaa5304" +dependencies = [ + "bytes 1.4.0", "futures 0.3.28", "http 0.2.9", "mime", @@ -826,7 +1406,7 @@ dependencies = [ "pathdiff", "ron", "rust-ini", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "toml 0.5.11", "yaml-rust 0.4.5", @@ -886,7 +1466,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "strum 0.26.1", @@ -926,7 +1506,7 @@ version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -995,7 +1575,7 @@ checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] @@ -1006,7 +1586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", - "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] @@ -1016,17 +1596,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array 0.14.7", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1047,7 +1627,7 @@ dependencies = [ "byteorder 1.4.3", "digest 0.8.1", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] @@ -1060,7 +1640,7 @@ dependencies = [ "byteorder 1.4.3", "digest 0.9.0", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] @@ -1101,9 +1681,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.6.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "der" @@ -1195,7 +1775,7 @@ dependencies = [ "block-buffer 0.10.4", "const-oid", "crypto-common", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1320,9 +1900,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -1333,7 +1913,7 @@ dependencies = [ "pkcs8", "rand_core 0.6.4", "sec1", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] @@ -1361,9 +1941,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -1451,7 +2031,7 @@ dependencies = [ "parity-scale-codec", "rlp", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sha3", "triehash", ] @@ -1506,7 +2086,7 @@ dependencies = [ "primitive-types", "rlp", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sha3", ] @@ -1526,7 +2106,7 @@ dependencies = [ "primitive-types", "rlp", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sha3", ] @@ -1558,7 +2138,7 @@ dependencies = [ "parity-scale-codec", "primitive-types", "scale-info", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -1569,7 +2149,7 @@ dependencies = [ "parity-scale-codec", "primitive-types", "scale-info", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -1714,7 +2294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1827,7 +2407,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "hex", "impl-serde", @@ -1835,9 +2415,9 @@ dependencies = [ "log 0.4.20", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -1853,9 +2433,9 @@ dependencies = [ "log 0.4.20", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-runtime-interface", "sp-std 5.0.0", @@ -1864,13 +2444,13 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "evm 0.39.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "sp-runtime", "sp-std 5.0.0", @@ -1885,7 +2465,7 @@ dependencies = [ "frame-support", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "sp-runtime", "sp-std 5.0.0", @@ -1900,7 +2480,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-support-procedural", @@ -1910,11 +2490,11 @@ dependencies = [ "parity-scale-codec", "paste", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-api", "sp-application-crypto", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-runtime-interface", "sp-std 5.0.0", @@ -1925,14 +2505,14 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-tracing", @@ -1947,13 +2527,13 @@ dependencies = [ "cfg-if 1.0.0", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bitflags 1.3.2", "environmental 1.1.4", @@ -1962,18 +2542,18 @@ dependencies = [ "impl-trait-for-tuples", "k256", "log 0.4.20", - "once_cell 1.18.0", + "once_cell 1.19.0", "parity-scale-codec", "paste", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "smallvec 1.11.0", "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-staking", "sp-state-machine", @@ -1986,7 +2566,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "cfg-expr", @@ -1996,43 +2576,43 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "log 0.4.20", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-version", @@ -2188,7 +2768,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -2207,7 +2787,7 @@ name = "futures-task" version = "0.3.8" source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" dependencies = [ - "once_cell 1.4.0", + "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx)", "sgx_tstd", ] @@ -2267,7 +2847,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] @@ -2276,7 +2856,7 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", "version_check", "zeroize", ] @@ -2338,9 +2918,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ "aho-corasick", "bstr", @@ -2357,7 +2937,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2548,7 +3128,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", "digest 0.9.0", ] @@ -2575,7 +3155,7 @@ dependencies = [ [[package]] name = "http" version = "0.2.1" -source = "git+https://github.com/integritee-network/http-sgx.git?branch=sgx-experimental#307b5421fb7a489a114bede0dc05c8d32b804f49" +source = "git+https://github.com/integritee-network/http-sgx?branch=sgx-experimental#307b5421fb7a489a114bede0dc05c8d32b804f49" dependencies = [ "bytes 1.0.1", "fnv 1.0.6", @@ -2724,26 +3304,375 @@ dependencies = [ ] [[package]] -name = "iana-time-zone" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "id-ita-parentchain-interface" +version = "0.1.0" +dependencies = [ + "env_logger 0.10.2", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itc-parentchain-indirect-calls-executor", + "id-itp-stf-executor", + "id-itp-top-pool-author", + "itc-parentchain-test", + "itp-api-client-types", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-test", + "itp-types", + "lc-dynamic-assertion", + "lc-evm-dynamic-assertions", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", + "sp-std 5.0.0", + "substrate-api-client", +] + +[[package]] +name = "id-ita-sgx-runtime" +version = "0.1.0" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "itp-sgx-runtime-primitives", + "pallet-balances", + "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", + "pallet-identity-management-tee", + "pallet-parentchain", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std 5.0.0", + "sp-version", +] + +[[package]] +name = "id-ita-stf" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "hex", + "hex-literal", + "id-ita-sgx-runtime", + "itp-hashing", + "itp-node-api", + "itp-node-api-metadata", + "itp-node-api-metadata-provider", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-storage", + "itp-types", + "itp-utils", + "lc-stf-task-sender", + "litentry-hex-utils 0.1.0", + "litentry-macros 0.1.0", + "litentry-primitives", + "log 0.4.20", + "pallet-balances", + "pallet-parentchain", + "pallet-sudo", + "parity-scale-codec", + "rlp", + "sgx_tstd", + "sha3", + "sp-core", + "sp-io 7.0.0", + "sp-keyring", + "sp-runtime", + "sp-std 5.0.0", +] + +[[package]] +name = "id-itc-direct-rpc-client" +version = "0.1.0" +dependencies = [ + "itp-rpc", + "itp-types", + "itp-utils", + "log 0.4.20", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", + "rustls 0.19.1", + "serde_json 1.0.103", + "sgx_tstd", + "tungstenite 0.14.0", + "tungstenite 0.15.0", + "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", + "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", +] + +[[package]] +name = "id-itc-direct-rpc-server" +version = "0.1.0" +dependencies = [ + "itc-tls-websocket-server", + "itp-rpc", + "itp-types", + "itp-utils", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "log 0.4.20", + "parity-scale-codec", + "serde_json 1.0.103", + "sgx_tstd", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itc-offchain-worker-executor" +version = "0.1.0" +dependencies = [ + "id-itp-stf-executor", + "id-itp-top-pool-author", + "itc-parentchain-light-client", + "itp-extrinsics-factory", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itc-parentchain" +version = "0.1.0" +dependencies = [ + "id-itc-parentchain-block-import-dispatcher", + "id-itc-parentchain-block-importer", + "id-itc-parentchain-indirect-calls-executor", + "itc-parentchain-light-client", + "itp-types", + "parity-scale-codec", + "sp-runtime", +] + +[[package]] +name = "id-itc-parentchain-block-import-dispatcher" +version = "0.1.0" +dependencies = [ + "id-itc-parentchain-block-importer", + "itp-import-queue", + "log 0.4.20", + "sgx_tstd", + "sgx_types", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itc-parentchain-block-importer" +version = "0.1.0" +dependencies = [ + "id-ita-stf", + "id-itc-parentchain-indirect-calls-executor", + "id-itp-stf-executor", + "itc-parentchain-light-client", + "itp-enclave-metrics", + "itp-extrinsics-factory", + "itp-ocall-api", + "itp-stf-interface", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itc-parentchain-indirect-calls-executor" +version = "0.1.0" +dependencies = [ + "binary-merkle-tree", + "bs58", + "env_logger 0.10.2", + "futures 0.3.28", + "futures 0.3.8", + "id-itp-stf-executor", + "id-itp-top-pool-author", + "itc-parentchain-test", + "itp-api-client-types", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-runtime-primitives", + "itp-stf-primitives", + "itp-test", + "itp-types", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itp-enclave-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "hex", + "id-itp-enclave-api-ffi", + "itp-settings", + "itp-sgx-crypto", + "itp-stf-interface", + "itp-storage", + "itp-types", + "log 0.4.20", + "pallet-teebag", + "parity-scale-codec", + "serde_json 1.0.103", + "sgx_crypto_helper", + "sgx_types", + "sgx_urts", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", +] + +[[package]] +name = "id-itp-enclave-api-ffi" +version = "0.1.0" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "id-itp-stf-executor" +version = "0.1.0" +dependencies = [ + "hex", + "id-itp-top-pool", + "id-itp-top-pool-author", + "itc-parentchain-test", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-stf-state-observer", + "itp-test", + "itp-time-utils", + "itp-types", + "log 0.4.20", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-core", + "sp-runtime", + "thiserror 1.0.44", + "thiserror 1.0.9", +] + +[[package]] +name = "id-itp-top-pool" +version = "0.1.0" dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows", + "byteorder 1.4.3", + "derive_more", + "id-itc-direct-rpc-server", + "itp-stf-primitives", + "itp-test", + "itp-types", + "its-primitives", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "linked-hash-map 0.5.2", + "linked-hash-map 0.5.6", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "parity-util-mem", + "serde 1.0.193", + "sgx_tstd", + "sp-application-crypto", + "sp-core", + "sp-runtime", ] [[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +name = "id-itp-top-pool-author" +version = "0.1.0" dependencies = [ - "cc", + "derive_more", + "futures 0.3.28", + "id-itp-top-pool", + "itp-enclave-metrics", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "itp-utils", + "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", + "lazy_static", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "sgx_crypto_helper", + "sgx_tstd", + "sp-core", + "sp-keyring", + "sp-runtime", ] [[package]] @@ -2806,7 +3735,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -2838,7 +3767,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg 1.1.0", "hashbrown 0.12.3", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -2854,323 +3783,89 @@ dependencies = [ [[package]] name = "instant" version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.2", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" -dependencies = [ - "sgx_libc", -] - -[[package]] -name = "ipfs-api" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3824538e42e84c792988098df4ad5a35b47be98b19e31454e09f4e322f00fc" -dependencies = [ - "bytes 1.4.0", - "dirs", - "failure", - "futures 0.3.28", - "http 0.2.9", - "hyper", - "hyper-multipart-rfc7578", - "hyper-tls", - "parity-multiaddr", - "serde 1.0.204", - "serde_json 1.0.103", - "serde_urlencoded", - "tokio", - "tokio-util 0.6.10", - "tracing", - "typed-builder", - "walkdir", -] - -[[package]] -name = "ipnet" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.4", - "windows-sys 0.48.0", -] - -[[package]] -name = "ita-parentchain-interface" -version = "0.1.0" -dependencies = [ - "env_logger 0.9.3", - "ita-sgx-runtime", - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-test", - "itp-api-client-types", - "itp-enclave-metrics", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-stf-executor", - "itp-stf-primitives", - "itp-test", - "itp-top-pool-author", - "itp-types", - "lc-dynamic-assertion", - "lc-evm-dynamic-assertions", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "sp-std 5.0.0", - "substrate-api-client", -] - -[[package]] -name = "ita-sgx-runtime" -version = "0.1.0" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "itp-sgx-runtime-primitives", - "pallet-balances", - "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", - "pallet-identity-management-tee", - "pallet-parentchain", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-runtime", - "sp-std 5.0.0", - "sp-version", -] - -[[package]] -name = "ita-stf" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "hex", - "hex-literal", - "ita-sgx-runtime", - "itp-hashing", - "itp-node-api", - "itp-node-api-metadata", - "itp-node-api-metadata-provider", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-storage", - "itp-types", - "itp-utils", - "lc-stf-task-sender", - "litentry-hex-utils 0.1.0", - "litentry-macros 0.1.0", - "litentry-primitives", - "log 0.4.20", - "pallet-balances", - "pallet-parentchain", - "pallet-sudo", - "parity-scale-codec", - "rlp", - "sgx_tstd", - "sha3", - "sp-core", - "sp-io 7.0.0", - "sp-keyring", - "sp-runtime", - "sp-std 5.0.0", -] - -[[package]] -name = "itc-direct-rpc-client" -version = "0.1.0" -dependencies = [ - "itp-rpc", - "itp-types", - "itp-utils", - "log 0.4.20", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", - "rustls 0.19.1", - "serde_json 1.0.103", - "sgx_tstd", - "tungstenite 0.14.0", - "tungstenite 0.15.0", - "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", ] [[package]] -name = "itc-direct-rpc-server" -version = "0.1.0" +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" dependencies = [ - "itc-tls-websocket-server", - "itp-rpc", - "itp-types", - "itp-utils", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "log 0.4.20", - "parity-scale-codec", - "serde_json 1.0.103", - "sgx_tstd", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", + "num-traits 0.2.16", ] [[package]] -name = "itc-offchain-worker-executor" -version = "0.1.0" +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "itc-parentchain-light-client", - "itp-extrinsics-factory", - "itp-sgx-externalities", - "itp-stf-executor", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool-author", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", + "hermit-abi 0.3.2", + "libc", + "windows-sys 0.48.0", ] [[package]] -name = "itc-parentchain" -version = "0.1.0" +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" dependencies = [ - "itc-parentchain-block-import-dispatcher", - "itc-parentchain-block-importer", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-types", - "parity-scale-codec", - "sp-runtime", + "libc", ] [[package]] -name = "itc-parentchain-block-import-dispatcher" -version = "0.1.0" +name = "iovec" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" dependencies = [ - "itc-parentchain-block-importer", - "itp-import-queue", - "log 0.4.20", - "sgx_tstd", - "sgx_types", - "thiserror 1.0.44", - "thiserror 1.0.9", + "sgx_libc", ] [[package]] -name = "itc-parentchain-block-importer" -version = "0.1.0" +name = "ipfs-api" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3824538e42e84c792988098df4ad5a35b47be98b19e31454e09f4e322f00fc" dependencies = [ - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-enclave-metrics", - "itp-extrinsics-factory", - "itp-ocall-api", - "itp-stf-executor", - "itp-stf-interface", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", + "bytes 1.4.0", + "dirs", + "failure", + "futures 0.3.28", + "http 0.2.9", + "hyper", + "hyper-multipart-rfc7578", + "hyper-tls", + "parity-multiaddr", + "serde 1.0.193", + "serde_json 1.0.103", + "serde_urlencoded", + "tokio", + "tokio-util 0.6.10", + "tracing", + "typed-builder", + "walkdir", ] [[package]] -name = "itc-parentchain-indirect-calls-executor" -version = "0.1.0" +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "binary-merkle-tree", - "env_logger 0.9.3", - "futures 0.3.28", - "futures 0.3.8", - "ita-parentchain-interface", - "itc-parentchain-test", - "itp-api-client-types", - "itp-enclave-metrics", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-stf-executor", - "itp-stf-primitives", - "itp-test", - "itp-top-pool-author", - "itp-types", - "lc-evm-dynamic-assertions", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", + "hermit-abi 0.3.2", + "rustix 0.38.4", + "windows-sys 0.48.0", ] [[package]] @@ -3207,8 +3902,8 @@ dependencies = [ name = "itc-peer-top-broadcaster" version = "0.1.0" dependencies = [ - "itc-direct-rpc-client", - "itc-direct-rpc-server", + "id-itc-direct-rpc-client", + "id-itc-direct-rpc-server", "itp-rpc", "itp-stf-primitives", "itp-types", @@ -3228,7 +3923,7 @@ dependencies = [ "http_req 0.8.1 (git+https://github.com/integritee-network/http_req?branch=master)", "http_req 0.8.1 (git+https://github.com/integritee-network/http_req)", "log 0.4.20", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_tstd", "thiserror 1.0.44", @@ -3241,9 +3936,8 @@ name = "itc-rpc-client" version = "0.1.0" dependencies = [ "base58", - "env_logger 0.9.3", + "env_logger 0.10.2", "frame-metadata", - "ita-stf", "itc-tls-websocket-server", "itp-api-client-types", "itp-networking-utils", @@ -3270,7 +3964,7 @@ name = "itc-rpc-server" version = "0.1.0" dependencies = [ "anyhow", - "env_logger 0.10.0", + "env_logger 0.10.2", "its-peer-fetch", "its-primitives", "its-storage", @@ -3286,14 +3980,14 @@ name = "itc-tls-websocket-server" version = "0.1.0" dependencies = [ "bit-vec", - "chrono 0.4.38", - "env_logger 0.9.3", + "chrono 0.4.26", + "env_logger 0.10.2", "log 0.4.20", "mio 0.6.21", "mio 0.6.23", "mio-extras 2.0.6 (git+https://github.com/integritee-network/mio-extras-sgx?rev=963234b)", "rcgen", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "rustls 0.19.1", "sgx_tstd", "sp-core", @@ -3368,7 +4062,7 @@ dependencies = [ "base64 0.13.1", "bit-vec", "chrono 0.4.11", - "chrono 0.4.38", + "chrono 0.4.26", "hex", "httparse 1.4.1", "itertools 0.10.5", @@ -3380,7 +4074,7 @@ dependencies = [ "log 0.4.20", "num-bigint 0.2.5", "parity-scale-codec", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "rustls 0.19.1", "serde_json 1.0.103", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", @@ -3404,7 +4098,7 @@ version = "0.8.0" dependencies = [ "binary-merkle-tree", "parity-scale-codec", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -3416,42 +4110,10 @@ dependencies = [ "thiserror 1.0.9", ] -[[package]] -name = "itp-enclave-api" -version = "0.1.0" -dependencies = [ - "frame-support", - "hex", - "itc-parentchain", - "itp-enclave-api-ffi", - "itp-settings", - "itp-stf-interface", - "itp-storage", - "itp-types", - "log 0.4.20", - "pallet-teebag", - "parity-scale-codec", - "serde_json 1.0.103", - "sgx_crypto_helper", - "sgx_types", - "sgx_urts", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", -] - -[[package]] -name = "itp-enclave-api-ffi" -version = "0.1.0" -dependencies = [ - "sgx_types", -] - [[package]] name = "itp-enclave-metrics" version = "0.1.0" dependencies = [ - "lc-stf-task-sender", "litentry-primitives", "parity-scale-codec", "sgx_tstd", @@ -3581,7 +4243,7 @@ version = "0.1.0" dependencies = [ "itp-types", "parity-scale-codec", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_tstd", ] @@ -3599,11 +4261,14 @@ version = "0.1.0" dependencies = [ "aes", "derive_more", + "hex", "itp-sgx-io", "itp-sgx-temp-dir", + "k256", "log 0.4.20", "ofb", "parity-scale-codec", + "secp256k1 0.28.0", "serde_json 1.0.103", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_crypto_helper", @@ -3624,7 +4289,7 @@ dependencies = [ "log 0.4.20", "parity-scale-codec", "postcard", - "serde 1.0.204", + "serde 1.0.193", "sgx_tstd", "sp-core", ] @@ -3655,36 +4320,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "itp-stf-executor" -version = "0.1.0" -dependencies = [ - "hex", - "itc-parentchain-test", - "itp-enclave-metrics", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-stf-state-observer", - "itp-test", - "itp-time-utils", - "itp-top-pool", - "itp-top-pool-author", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - [[package]] name = "itp-stf-interface" version = "0.8.0" @@ -3799,62 +4434,8 @@ name = "itp-time-utils" version = "0.1.0" dependencies = [ "chrono 0.4.11", - "chrono 0.4.38", - "sgx_tstd", -] - -[[package]] -name = "itp-top-pool" -version = "0.1.0" -dependencies = [ - "byteorder 1.4.3", - "derive_more", - "itc-direct-rpc-server", - "itp-stf-primitives", - "itp-test", - "itp-types", - "its-primitives", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "linked-hash-map 0.5.2", - "linked-hash-map 0.5.6", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "parity-util-mem", - "serde 1.0.204", - "sgx_tstd", - "sp-application-crypto", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "itp-top-pool-author" -version = "0.1.0" -dependencies = [ - "derive_more", - "futures 0.3.28", - "itp-enclave-metrics", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool", - "itp-types", - "itp-utils", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "lazy_static", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_crypto_helper", + "chrono 0.4.26", "sgx_tstd", - "sp-core", - "sp-keyring", - "sp-runtime", ] [[package]] @@ -3869,7 +4450,8 @@ dependencies = [ "litentry-primitives", "pallet-balances", "parity-scale-codec", - "serde 1.0.204", + "serde 1.0.193", + "sp-consensus-grandpa", "sp-core", "sp-runtime", "sp-std 5.0.0", @@ -3889,14 +4471,14 @@ dependencies = [ name = "its-block-composer" version = "0.1.0" dependencies = [ + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-node-api", "itp-settings", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-time-utils", - "itp-top-pool-author", "itp-types", "its-primitives", "its-state", @@ -3934,10 +4516,12 @@ dependencies = [ name = "its-consensus-aura" version = "0.1.0" dependencies = [ - "env_logger 0.9.3", + "env_logger 0.10.2", "finality-grandpa", - "ita-stf", - "itc-parentchain-block-import-dispatcher", + "id-ita-stf", + "id-itc-parentchain-block-import-dispatcher", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itc-parentchain-test", "itc-peer-top-broadcaster", "itp-enclave-metrics", @@ -3945,13 +4529,11 @@ dependencies = [ "itp-settings", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", "itp-storage", "itp-test", "itp-time-utils", - "itp-top-pool-author", "itp-types", "its-block-composer", "its-block-verification", @@ -4045,7 +4627,7 @@ dependencies = [ "its-test", "jsonrpsee", "log 0.4.20", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "thiserror 1.0.44", "tokio", @@ -4058,7 +4640,7 @@ dependencies = [ "itp-types", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "sp-runtime", "sp-std 5.0.0", @@ -4070,10 +4652,10 @@ version = "0.1.0" dependencies = [ "futures 0.3.28", "futures 0.3.8", + "id-itp-top-pool-author", "itp-import-queue", "itp-rpc", "itp-stf-primitives", - "itp-top-pool-author", "itp-types", "itp-utils", "its-primitives", @@ -4135,7 +4717,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "rocksdb", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "temp-dir", "thiserror 1.0.44", @@ -4169,9 +4751,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -4193,7 +4775,7 @@ checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" dependencies = [ "pest", "pest_derive", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -4206,8 +4788,8 @@ dependencies = [ "futures-executor 0.3.28", "futures-util 0.3.28", "log 0.4.20", - "serde 1.0.204", - "serde_derive 1.0.204", + "serde 1.0.193", + "serde_derive 1.0.193", "serde_json 1.0.103", ] @@ -4251,7 +4833,7 @@ dependencies = [ "jsonrpsee-types", "jsonrpsee-utils", "log 0.4.20", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "thiserror 1.0.44", "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4271,7 +4853,7 @@ dependencies = [ "jsonrpsee-utils", "lazy_static", "log 0.4.20", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "socket2", "thiserror 1.0.44", @@ -4304,7 +4886,7 @@ dependencies = [ "futures-util 0.3.28", "hyper", "log 0.4.20", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "soketto", "thiserror 1.0.44", @@ -4324,7 +4906,7 @@ dependencies = [ "parking_lot 0.11.2", "rand 0.8.5", "rustc-hash", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "thiserror 1.0.44", ] @@ -4343,7 +4925,7 @@ dependencies = [ "pin-project", "rustls 0.19.1", "rustls-native-certs", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "soketto", "thiserror 1.0.44", @@ -4365,7 +4947,7 @@ dependencies = [ "jsonrpsee-utils", "log 0.4.20", "rustc-hash", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "soketto", "thiserror 1.0.44", @@ -4376,15 +4958,16 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if 1.0.0", "ecdsa", "elliptic-curve", - "once_cell 1.18.0", - "sha2 0.10.7", + "once_cell 1.19.0", + "sha2 0.10.8", + "signature 2.1.0", ] [[package]] @@ -4426,8 +5009,8 @@ name = "lc-assertion-build" version = "0.1.0" dependencies = [ "blake2-rfc", - "chrono 0.4.38", - "env_logger 0.10.0", + "chrono 0.4.26", + "env_logger 0.10.2", "ethabi", "frame-support", "hex", @@ -4447,7 +5030,6 @@ dependencies = [ "lc-dynamic-assertion", "lc-evm-dynamic-assertions", "lc-mock-server", - "lc-stf-task-sender", "litentry-hex-utils 0.1.0", "litentry-primitives", "log 0.4.20", @@ -4456,7 +5038,7 @@ dependencies = [ "primitive-types", "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (git+https://github.com/mesalock-linux/rust-base58-sgx)", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_tstd", "sp-core", @@ -4469,7 +5051,7 @@ name = "lc-assertion-build-v2" version = "0.1.0" dependencies = [ "base58", - "env_logger 0.10.0", + "env_logger 0.10.2", "itc-rest-client", "itp-ocall-api", "itp-stf-primitives", @@ -4480,7 +5062,6 @@ dependencies = [ "lc-credentials-v2", "lc-mock-server", "lc-service", - "lc-stf-task-sender", "litentry-hex-utils 0.1.0", "litentry-primitives", "log 0.4.20", @@ -4503,7 +5084,7 @@ name = "lc-credentials" version = "0.1.0" dependencies = [ "chrono 0.4.11", - "chrono 0.4.38", + "chrono 0.4.26", "itp-stf-primitives", "itp-time-utils", "itp-types", @@ -4517,7 +5098,7 @@ dependencies = [ "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rust-base58 0.0.4 (git+https://github.com/mesalock-linux/rust-base58-sgx)", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_tstd", @@ -4540,10 +5121,10 @@ dependencies = [ name = "lc-data-providers" version = "0.1.0" dependencies = [ - "base64 0.22.0", + "base64 0.13.1", "chrono 0.4.11", - "chrono 0.4.38", - "env_logger 0.10.0", + "chrono 0.4.26", + "env_logger 0.10.2", "http 0.2.1", "http 0.2.9", "http_req 0.8.1 (git+https://github.com/integritee-network/http_req?branch=master)", @@ -4556,7 +5137,7 @@ dependencies = [ "litentry-primitives", "log 0.4.20", "parity-scale-codec", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_tstd", "thiserror 1.0.44", @@ -4564,6 +5145,27 @@ dependencies = [ "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", ] +[[package]] +name = "lc-direct-call" +version = "0.1.0" +dependencies = [ + "bc-enclave-registry", + "bc-musig2-ceremony", + "bc-relayer-registry", + "bc-signer-registry", + "hex", + "itp-sgx-crypto", + "itp-stf-primitives", + "k256", + "litentry-primitives", + "log 0.4.20", + "parity-scale-codec", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sgx_tstd", + "sp-core", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", +] + [[package]] name = "lc-dynamic-assertion" version = "0.1.0" @@ -4579,7 +5181,7 @@ dependencies = [ "base58", "blake2-rfc", "chrono 0.4.11", - "chrono 0.4.38", + "chrono 0.4.26", "ethabi", "evm 0.41.1", "hex", @@ -4610,7 +5212,7 @@ dependencies = [ name = "lc-identity-verification" version = "0.1.0" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "frame-support", "futures 0.3.8", "hex", @@ -4623,13 +5225,12 @@ dependencies = [ "itp-utils", "lazy_static", "lc-data-providers", - "lc-stf-task-sender", "litentry-primitives", "log 0.4.20", "lru", "parity-scale-codec", "rand 0.8.5", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_rand", "sgx_tstd", @@ -4643,7 +5244,7 @@ name = "lc-mock-server" version = "0.1.0" dependencies = [ "hex", - "ita-stf", + "id-ita-stf", "itp-rpc", "lc-data-providers", "litentry-primitives", @@ -4696,18 +5297,18 @@ dependencies = [ "futures 0.3.28", "futures 0.3.8", "hex", - "ita-sgx-runtime", - "ita-stf", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itp-stf-executor", + "id-itp-top-pool", + "id-itp-top-pool-author", "itp-enclave-metrics", "itp-ocall-api", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", "itp-test", - "itp-top-pool", - "itp-top-pool-author", "itp-types", "itp-utils", "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4762,18 +5363,18 @@ dependencies = [ "frame-support", "futures 0.3.28", "futures 0.3.8", - "ita-sgx-runtime", - "ita-stf", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-enclave-metrics", "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", "itp-storage", - "itp-top-pool-author", "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", @@ -4802,18 +5403,18 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if 1.0.0", - "winapi 0.3.9", + "windows-targets 0.48.1", ] [[package]] @@ -4850,9 +5451,9 @@ dependencies = [ "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", "rand 0.8.5", - "serde 1.0.204", + "serde 1.0.193", "sha2 0.9.9", - "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] @@ -4863,7 +5464,7 @@ checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", "digest 0.9.0", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4886,9 +5487,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.10" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e6ab01971eb092ffe6a7d42f49f9ff42662f17604681e2843ad65077ba47dc" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "pkg-config", @@ -4940,17 +5541,17 @@ checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" name = "litentry-cli" version = "0.0.1" dependencies = [ - "array-bytes 6.1.0", + "array-bytes 6.2.3", "base58", - "chrono 0.4.38", + "chrono 0.4.26", "clap 4.1.0", - "env_logger 0.9.3", + "env_logger 0.10.2", "frame-metadata", "hdrhistogram", "hex", - "ita-parentchain-interface", - "ita-sgx-runtime", - "ita-stf", + "id-ita-parentchain-interface", + "id-ita-sgx-runtime", + "id-ita-stf", "itc-rpc-client", "itp-node-api", "itp-rpc", @@ -4961,14 +5562,14 @@ dependencies = [ "litentry-hex-utils 0.1.0", "litentry-primitives", "log 0.4.20", - "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", + "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", "parity-scale-codec", "rand 0.8.5", "rayon", "regex 1.9.5", "reqwest", "scale-value", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sgx_crypto_helper", "sp-application-crypto", @@ -5016,6 +5617,7 @@ dependencies = [ "core-primitives", "hex", "itp-sgx-crypto", + "itp-sgx-runtime-primitives", "log 0.4.20", "pallet-teebag", "parity-scale-codec", @@ -5024,10 +5626,10 @@ dependencies = [ "ring 0.16.20", "scale-info", "secp256k1 0.28.0", - "serde 1.0.204", + "serde 1.0.193", "sgx_tstd", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -5040,7 +5642,7 @@ dependencies = [ "cargo_toml", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -5058,15 +5660,14 @@ dependencies = [ "futures 0.3.28", "hex", "humantime", + "id-ita-parentchain-interface", + "id-itp-enclave-api", "ipfs-api", - "ita-parentchain-interface", - "itc-parentchain", "itc-parentchain-test", "itc-rest-client", "itc-rpc-client", "itc-rpc-server", "itp-api-client-types", - "itp-enclave-api", "itp-enclave-metrics", "itp-node-api", "itp-settings", @@ -5085,7 +5686,6 @@ dependencies = [ "lazy_static", "lc-data-providers", "lc-mock-server", - "lc-stf-task-sender", "litentry-macros 0.1.0", "litentry-primitives", "log 0.4.20", @@ -5098,8 +5698,8 @@ dependencies = [ "rayon", "regex 1.9.5", "scale-info", - "serde 1.0.204", - "serde_derive 1.0.204", + "serde 1.0.193", + "serde_derive 1.0.193", "serde_json 1.0.103", "sgx_crypto_helper", "sgx_types", @@ -5114,6 +5714,14 @@ dependencies = [ "warp", ] +[[package]] +name = "litentry-worker-macros" +version = "0.1.0" +dependencies = [ + "cargo_toml", + "quote", +] + [[package]] name = "lock_api" version = "0.4.10" @@ -5150,9 +5758,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown 0.14.0", ] @@ -5337,9 +5945,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -5454,6 +6062,38 @@ dependencies = [ "synstructure", ] +[[package]] +name = "musig2" +version = "0.0.8" +source = "git+https://github.com/kziemianek/musig2?branch=master#cd5e61ac9ecdf842da58605ac7b07b6e359f08c5" +dependencies = [ + "base16ct", + "hmac 0.12.1", + "k256", + "once_cell 1.19.0", + "secp 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "secp256k1 0.28.0", + "sha2 0.10.8", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "musig2" +version = "0.0.8" +source = "git+https://github.com/kailai-wang/musig2?branch=use-sha2-0.8#93857e52abbe8f9898c9ec743eecb1380132abcb" +dependencies = [ + "base16ct", + "hmac 0.12.1", + "k256", + "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx?branch=master)", + "secp 0.2.3 (git+https://github.com/kziemianek/secp.git?branch=sgx)", + "secp256k1 0.28.0", + "sgx_tstd", + "sha2 0.10.8", + "sha2_v08_wrapper", + "subtle 2.5.0 (git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update)", +] + [[package]] name = "nalgebra" version = "0.32.3" @@ -5467,7 +6107,7 @@ dependencies = [ "num-rational 0.4.1", "num-traits 0.2.16", "simba", - "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] @@ -5657,17 +6297,6 @@ dependencies = [ "num-traits 0.2.16", ] -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "num-format" version = "0.4.4" @@ -5821,6 +6450,14 @@ dependencies = [ "cipher", ] +[[package]] +name = "once_cell" +version = "1.4.0" +source = "git+https://github.com/mesalock-linux/once_cell-sgx?branch=master#cefcaa03fed4d85276b3235d875f1b45d399cc3c" +dependencies = [ + "sgx_tstd", +] + [[package]] name = "once_cell" version = "1.4.0" @@ -5831,9 +6468,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -5857,7 +6494,7 @@ dependencies = [ "cfg-if 1.0.0", "foreign-types", "libc", - "once_cell 1.18.0", + "once_cell 1.19.0", "openssl-macros", "openssl-sys", ] @@ -5870,7 +6507,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -5910,7 +6547,7 @@ checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -5925,7 +6562,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -5939,7 +6576,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -5954,12 +6591,12 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "environmental 1.1.4", "evm 0.39.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fp-account 1.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", - "fp-evm 3.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", + "fp-account 1.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", + "fp-evm 3.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", "frame-benchmarking", "frame-support", "frame-system", @@ -5970,7 +6607,7 @@ dependencies = [ "rlp", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -5995,7 +6632,7 @@ dependencies = [ "rlp", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6013,7 +6650,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6047,14 +6684,14 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", ] [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -6064,7 +6701,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-session", "sp-staking", @@ -6074,13 +6711,13 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6091,7 +6728,7 @@ version = "0.1.0" source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#cdbe9b02c1c58ca3d0063bf2eaf26a1f9da314e9" dependencies = [ "base64 0.13.1", - "chrono 0.4.38", + "chrono 0.4.26", "der 0.6.1", "frame-support", "frame-system", @@ -6104,10 +6741,10 @@ dependencies = [ "ring 0.16.20", "rustls-webpki", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "x509-cert", @@ -6116,7 +6753,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -6125,7 +6762,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-timestamp", @@ -6134,15 +6771,15 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6159,7 +6796,7 @@ dependencies = [ "data-encoding", "multihash", "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.204", + "serde 1.0.193", "static_assertions", "unsigned-varint 0.7.1", "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6177,7 +6814,7 @@ dependencies = [ "bytes 1.4.0", "impl-trait-for-tuples", "parity-scale-codec-derive", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -6299,7 +6936,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", ] [[package]] @@ -6323,7 +6960,7 @@ version = "0.8.2" source = "git+https://github.com/mesalock-linux/pem-rs-sgx#fdfef4f24a9fb3fa72e8a71bb28bd8ff15feff2f" dependencies = [ "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "once_cell 1.4.0", + "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx)", "regex 1.3.1", "sgx_tstd", ] @@ -6383,7 +7020,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -6392,9 +7029,9 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2674c66ebb4b4d9036012091b537aae5878970d6999f81a265034d85b136b341" dependencies = [ - "once_cell 1.18.0", + "once_cell 1.19.0", "pest", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -6414,14 +7051,14 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -6452,7 +7089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a25c0b0ae06fcffe600ad392aabfa535696c8973f2253d9ac83171924c58a858" dependencies = [ "postcard-cobs", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -6522,7 +7159,7 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ - "once_cell 1.18.0", + "once_cell 1.19.0", "toml_edit 0.19.15", ] @@ -6570,14 +7207,14 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -6620,31 +7257,11 @@ dependencies = [ "cc", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "quote" -version = "1.0.36" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -6803,7 +7420,7 @@ version = "0.9.2" source = "git+https://github.com/integritee-network/rcgen#1852c8dbeb74de36a422d218254b659497daf717" dependencies = [ "chrono 0.4.11", - "chrono 0.4.38", + "chrono 0.4.26", "pem 0.8.2", "pem 1.1.1", "ring 0.16.19", @@ -6868,7 +7485,7 @@ checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -6953,10 +7570,10 @@ dependencies = [ "log 0.4.20", "mime", "native-tls", - "once_cell 1.18.0", + "once_cell 1.19.0", "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "serde_urlencoded", "tokio", @@ -6976,7 +7593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac 0.12.1", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6993,41 +7610,16 @@ dependencies = [ [[package]] name = "ring" version = "0.16.20" -source = "git+https://github.com/betrusted-io/ring-xous?branch=0.16.20-cleanup#4296c2e7904898766cf7d8d589759a129794783b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", - "log 0.4.20", - "once_cell 1.18.0", - "rkyv", + "once_cell 1.19.0", "spin 0.5.2", "untrusted 0.7.1", + "web-sys", "winapi 0.3.9", - "xous", - "xous-api-names", - "xous-ipc", -] - -[[package]] -name = "rkyv" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70de01b38fe7baba4ecdd33b777096d2b326993d8ea99bc5b6ede691883d3010" -dependencies = [ - "memoffset 0.6.5", - "ptr_meta", - "rkyv_derive", -] - -[[package]] -name = "rkyv_derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a169f6bc5a81033e86ed39d0f4150e2608160b73d2b93c6e8e6a3efa873f14" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", ] [[package]] @@ -7070,7 +7662,7 @@ checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ "base64 0.13.1", "bitflags 1.3.2", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7112,9 +7704,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ "arrayvec 0.7.4", "num-traits 0.2.16", @@ -7214,19 +7806,6 @@ dependencies = [ "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", ] -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "ring 0.16.19", - "sct 0.6.0", - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - [[package]] name = "rustls" version = "0.19.1" @@ -7316,7 +7895,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -7336,7 +7915,7 @@ checksum = "8dd7aca73785181cc41f0bbe017263e682b585ca660540ba569133901d013ecf" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7347,7 +7926,7 @@ checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7427,7 +8006,7 @@ dependencies = [ "derive_more", "parity-scale-codec", "scale-info-derive", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7454,7 +8033,7 @@ dependencies = [ "scale-bits 0.3.0", "scale-decode 0.4.0", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "thiserror 1.0.44", "yap", ] @@ -7493,7 +8072,7 @@ dependencies = [ "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.2", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] @@ -7539,10 +8118,36 @@ dependencies = [ "der 0.7.8", "generic-array 0.14.7", "pkcs8", - "subtle", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize", ] +[[package]] +name = "secp" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1507279bb0404bb566f85523e48fcf37a158daa5380577ee0d93f3ef4df39ccc" +dependencies = [ + "base16ct", + "k256", + "once_cell 1.19.0", + "secp256k1 0.28.0", + "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "secp" +version = "0.2.3" +source = "git+https://github.com/kziemianek/secp.git?branch=sgx#0479a3b12fc204015cdb63c138078fefe7e32341" +dependencies = [ + "base16ct", + "k256", + "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx?branch=master)", + "secp256k1 0.28.0", + "sgx_tstd", + "subtle 2.5.0 (git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update)", +] + [[package]] name = "secp256k1" version = "0.24.3" @@ -7629,11 +8234,11 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ - "serde_derive 1.0.204", + "serde_derive 1.0.193", ] [[package]] @@ -7642,8 +8247,8 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b926cfbabfe8011609dda0350cb24d884955d294909ac71c0db7027366c77e3e" dependencies = [ - "serde 1.0.204", - "serde_derive 1.0.204", + "serde 1.0.193", + "serde_derive 1.0.193", ] [[package]] @@ -7667,13 +8272,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -7708,7 +8313,7 @@ dependencies = [ "indexmap 2.0.0", "itoa 1.0.9", "ryu", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7717,7 +8322,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7729,7 +8334,7 @@ dependencies = [ "form_urlencoded 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 1.0.9", "ryu", - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -7760,11 +8365,11 @@ dependencies = [ "itertools 0.11.0", "libc", "serde 1.0.118", - "serde 1.0.204", + "serde 1.0.193", "serde-big-array 0.1.5", "serde-big-array 0.3.0", "serde_derive 1.0.118", - "serde_derive 1.0.204", + "serde_derive 1.0.193", "sgx_tcrypto", "sgx_tstd", "sgx_types", @@ -7823,7 +8428,7 @@ dependencies = [ [[package]] name = "sgx_tse" version = "1.1.6" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_types", ] @@ -7948,15 +8553,23 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if 1.0.0", "cpufeatures", "digest 0.10.7", ] +[[package]] +name = "sha2_v08_wrapper" +version = "0.1.0" +source = "git+https://github.com/kailai-wang/sha2_v08#c41176becc675e84cd708e8b18ba2cd0c9cf8eb0" +dependencies = [ + "sha2 0.8.2", +] + [[package]] name = "sha3" version = "0.10.8" @@ -7978,9 +8591,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" @@ -8079,7 +8692,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "log 0.4.20", @@ -8099,7 +8712,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "blake2", @@ -8107,32 +8720,32 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-std 5.0.0", ] [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "integer-sqrt", "num-traits 0.2.16", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-std 5.0.0", "static_assertions", ] @@ -8140,13 +8753,13 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "finality-grandpa", "log 0.4.20", "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-api", "sp-application-crypto", "sp-core", @@ -8158,11 +8771,11 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-std 5.0.0", "sp-timestamp", ] @@ -8170,7 +8783,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", "bitflags 1.3.2", @@ -8197,7 +8810,7 @@ dependencies = [ "schnorrkel", "secp256k1 0.24.3", "secrecy", - "serde 1.0.204", + "serde 1.0.193", "sp-core-hashing 5.0.0", "sp-debug-derive", "sp-externalities", @@ -8214,12 +8827,12 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "blake2b_simd", "byteorder 1.4.3", "digest 0.10.7", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "sp-std 5.0.0", "twox-hash", @@ -8234,7 +8847,7 @@ dependencies = [ "blake2", "byteorder 1.4.3", "digest 0.10.7", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "sp-std 6.0.0", "twox-hash", @@ -8243,28 +8856,28 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", "sp-core-hashing 5.0.0", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "environmental 1.1.4", "parity-scale-codec", @@ -8275,7 +8888,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -8302,7 +8915,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.4.0", "ed25519", @@ -8328,7 +8941,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "lazy_static", "sp-core", @@ -8339,12 +8952,12 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "futures 0.3.28", "parity-scale-codec", "parking_lot 0.12.1", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "sp-externalities", "thiserror 1.0.44", @@ -8353,7 +8966,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -8364,7 +8977,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "backtrace", "lazy_static", @@ -8374,7 +8987,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "either", "hash256-std-hasher", @@ -8384,11 +8997,11 @@ dependencies = [ "paste", "rand 0.8.5", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-application-crypto", "sp-arithmetic", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", "sp-std 5.0.0", "sp-weights", ] @@ -8396,7 +9009,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.4.0", "impl-trait-for-tuples", @@ -8414,19 +9027,19 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -8439,11 +9052,11 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core", "sp-runtime", "sp-std 5.0.0", @@ -8452,7 +9065,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "log 0.4.20", @@ -8472,7 +9085,7 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" [[package]] name = "sp-std" @@ -8483,12 +9096,12 @@ checksum = "af0ee286f98455272f64ac5bb1384ff21ac029fbb669afbaf48477faff12760e" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-serde", "parity-scale-codec", "ref-cast", - "serde 1.0.204", + "serde 1.0.193", "sp-debug-derive", "sp-std 5.0.0", ] @@ -8496,7 +9109,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "async-trait", "futures-timer", @@ -8511,7 +9124,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-std 5.0.0", @@ -8523,7 +9136,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -8546,13 +9159,13 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-serde", "parity-scale-codec", "parity-wasm", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "sp-core-hashing-proc-macro", "sp-runtime", "sp-std 5.0.0", @@ -8563,18 +9176,18 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -8588,11 +9201,11 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", - "serde 1.0.204", + "serde 1.0.193", "smallvec 1.11.0", "sp-arithmetic", "sp-core", @@ -8642,7 +9255,7 @@ dependencies = [ "num-format", "proc-macro2", "quote", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "unicode-xid", ] @@ -8709,13 +9322,13 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-compose-macros", "ac-node-api", @@ -8728,7 +9341,7 @@ dependencies = [ "log 0.4.20", "maybe-async", "parity-scale-codec", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sp-core", "sp-runtime", @@ -8753,7 +9366,7 @@ dependencies = [ [[package]] name = "substrate-client-keystore" version = "0.9.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -8769,18 +9382,36 @@ dependencies = [ [[package]] name = "substrate-fixed" version = "0.5.9" -source = "git+https://github.com/encointer/substrate-fixed#a4fb461aae6205ffc55bed51254a40c52be04e5d" +source = "git+https://github.com/encointer/substrate-fixed#879c58bcc6fd676a74315dcd38b598f28708b0b5" +dependencies = [ + "parity-scale-codec", + "scale-info", + "substrate-typenum", +] + +[[package]] +name = "substrate-typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f0091e93c2c75b233ae39424c52cb8a662c0811fb68add149e20e5d7e8a788" dependencies = [ "parity-scale-codec", "scale-info", - "typenum 1.16.0 (git+https://github.com/encointer/typenum?tag=v1.16.0)", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update#57c424bdb6b98cbf9cfe19879748f20c3525c80e" +dependencies = [ + "sgx_tstd", +] [[package]] name = "syn" @@ -8795,9 +9426,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -8830,9 +9461,9 @@ checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "temp-dir" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab" +checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231" [[package]] name = "tempfile" @@ -8907,7 +9538,7 @@ checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -8917,7 +9548,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ "cfg-if 1.0.0", - "once_cell 1.18.0", + "once_cell 1.19.0", +] + +[[package]] +name = "threadpool" +version = "1.8.0" +source = "git+https://github.com/mesalock-linux/rust-threadpool-sgx?tag=sgx_1.1.3#098d98a85b7e2b02e2bb451a3dec0b027017ff4c" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus 1.16.0", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", ] [[package]] @@ -8928,11 +9587,11 @@ checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" dependencies = [ "anyhow", "hmac 0.12.1", - "once_cell 1.18.0", + "once_cell 1.19.0", "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror 1.0.44", "unicode-normalization 0.1.22", "wasm-bindgen", @@ -8973,7 +9632,7 @@ dependencies = [ "backtrace", "bytes 1.4.0", "libc", - "mio 0.8.11", + "mio 0.8.8", "num_cpus 1.16.0", "parking_lot 0.12.1", "pin-project-lite", @@ -8991,7 +9650,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -9073,7 +9732,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -9082,7 +9741,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", "serde_spanned", "toml_datetime", "toml_edit 0.20.2", @@ -9094,7 +9753,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", ] [[package]] @@ -9115,7 +9774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap 2.0.0", - "serde 1.0.204", + "serde 1.0.193", "serde_spanned", "toml_datetime", "winnow", @@ -9148,7 +9807,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] [[package]] @@ -9157,7 +9816,7 @@ version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ - "once_cell 1.18.0", + "once_cell 1.19.0", "valuable", ] @@ -9178,7 +9837,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ - "serde 1.0.204", + "serde 1.0.193", "tracing-core", ] @@ -9189,11 +9848,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" dependencies = [ "ansi_term", - "chrono 0.4.38", + "chrono 0.4.26", "lazy_static", "matchers", "regex 1.9.5", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "sharded-slab", "smallvec 1.11.0", @@ -9341,15 +10000,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "typenum" -version = "1.16.0" -source = "git+https://github.com/encointer/typenum?tag=v1.16.0#4c8dddaa8bdd13130149e43b4085ad14e960617f" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "ucd-trie" version = "0.1.6" @@ -9576,7 +10226,7 @@ dependencies = [ "pin-project", "rustls-pemfile", "scoped-tls", - "serde 1.0.204", + "serde 1.0.193", "serde_json 1.0.103", "serde_urlencoded", "tokio", @@ -9593,6 +10243,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -9617,10 +10273,10 @@ checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log 0.4.20", - "once_cell 1.18.0", + "once_cell 1.19.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", "wasm-bindgen-shared", ] @@ -9654,7 +10310,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9721,10 +10377,10 @@ dependencies = [ "libc", "log 0.4.20", "object 0.29.0", - "once_cell 1.18.0", + "once_cell 1.19.0", "paste", "psm", - "serde 1.0.204", + "serde 1.0.193", "target-lexicon", "wasmparser", "wasmtime-environ", @@ -9754,7 +10410,7 @@ dependencies = [ "indexmap 1.9.3", "log 0.4.20", "object 0.29.0", - "serde 1.0.204", + "serde 1.0.193", "target-lexicon", "thiserror 1.0.44", "wasmparser", @@ -9776,7 +10432,7 @@ dependencies = [ "log 0.4.20", "object 0.29.0", "rustc-demangle", - "serde 1.0.204", + "serde 1.0.193", "target-lexicon", "wasmtime-environ", "wasmtime-jit-icache-coherence", @@ -9790,7 +10446,7 @@ version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ - "once_cell 1.18.0", + "once_cell 1.19.0", ] [[package]] @@ -9835,7 +10491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" dependencies = [ "cranelift-entity", - "serde 1.0.204", + "serde 1.0.193", "thiserror 1.0.44", "wasmparser", ] @@ -10022,22 +10678,6 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -10050,12 +10690,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -10068,12 +10702,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -10086,18 +10714,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -10110,12 +10726,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -10128,12 +10738,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -10146,12 +10750,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -10164,12 +10762,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "winnow" version = "0.5.1" @@ -10239,54 +10831,6 @@ dependencies = [ "spki 0.6.0", ] -[[package]] -name = "xous" -version = "0.9.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a9f0a696320940ab2652fa1d20c98dc59eb7ba4591eeb91a3b8e40bc9255a1" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "xous-api-log" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e07c190c743d6d9e076f715333e94c48de41b99078343d174c707803df28c7" -dependencies = [ - "log 0.4.20", - "num-derive", - "num-traits 0.2.16", - "xous", - "xous-ipc", -] - -[[package]] -name = "xous-api-names" -version = "0.9.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d8361077e67966d25922056284d17d042cbb1c96a7ebc2584eb8181427cbb0" -dependencies = [ - "log 0.4.20", - "num-derive", - "num-traits 0.2.16", - "rkyv", - "xous", - "xous-api-log", - "xous-ipc", -] - -[[package]] -name = "xous-ipc" -version = "0.9.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee1d318dacbd6242e4e2291dee7c4532249e5a0845de05d264c20fc871a0a1a" -dependencies = [ - "bitflags 1.3.2", - "rkyv", - "xous", -] - [[package]] name = "yaml-rust" version = "0.3.5" @@ -10326,15 +10870,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e262a29d0e61ccf2b6190d7050d4b237535fc76ce4c1210d9caa316f71dffa75" dependencies = [ "bit-vec", - "chrono 0.4.38", + "chrono 0.4.26", "num-bigint 0.4.3", ] [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -10347,5 +10891,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.32", ] diff --git a/tee-worker/Cargo.toml b/tee-worker/Cargo.toml new file mode 100644 index 0000000000..fd82b102bb --- /dev/null +++ b/tee-worker/Cargo.toml @@ -0,0 +1,331 @@ +[workspace] +resolver = "2" +members = [ + # common + "common/core-primitives/sgx/crypto", + "common/core-primitives/sgx/io", + "common/core-primitives/sgx/temp-dir", + "common/core-primitives/substrate-sgx/environmental", + "common/core-primitives/substrate-sgx/externalities", + "common/core-primitives/substrate-sgx/sp-io", + "common/core-primitives/node-api", + "common/core-primitives/node-api/api-client-extensions", + "common/core-primitives/node-api/api-client-types", + "common/core-primitives/node-api/factory", + "common/core-primitives/node-api/metadata", + "common/core-primitives/node-api/metadata-provider", + "common/core-primitives/*", + + "common/litentry/core/parachain-extrinsic-task/sender", + "common/litentry/core/parachain-extrinsic-task/receiver", + "common/litentry/core/teebag-storage", + "common/litentry/macros", + "common/litentry/pallets/identity-management", + "common/litentry/primitives", + + "common/core/parentchain/light-client", + "common/core/parentchain/test", + "common/core/rest-client", + "common/core/rpc-client", + "common/core/tls-websocket-server", + + # identity-worker + "identity/app-libs/*", + "identity/cli", + "identity/core/parentchain/block-import-dispatcher", + "identity/core/parentchain/block-importer", + "identity/core/parentchain/indirect-calls-executor", + "identity/core/parentchain/parentchain-crate", + "identity/core/direct-rpc-client", + "identity/core/direct-rpc-server", + "identity/core/offchain-worker-executor", + "identity/core/peer-top-broadcaster", + "identity/core/rpc-server", + "identity/core-primitives/stf-executor", + "identity/core-primitives/top-pool", + "identity/core-primitives/top-pool-author", + "identity/core-primitives/enclave-api", + "identity/core-primitives/enclave-api/ffi", + "identity/service", + "identity/litentry/core/assertion-build", + "identity/litentry/core/assertion-build-v2", + "identity/litentry/core/common", + "identity/litentry/core/data-providers", + "identity/litentry/core/vc-task/sender", + "identity/litentry/core/vc-task/receiver", + "identity/litentry/core/identity-verification", + "identity/litentry/core/stf-task/sender", + "identity/litentry/core/stf-task/receiver", + "identity/litentry/core/service", + "identity/litentry/core/mock-server", + "identity/litentry/core/credentials-v2", + "identity/litentry/core/credentials", + "identity/litentry/core/dynamic-assertion", + "identity/litentry/core/evm-dynamic-assertions", + "identity/sidechain/*", + "identity/sidechain/consensus/slots", + "identity/sidechain/consensus/common", + "identity/sidechain/consensus/aura", + + # bitacross-worker + "bitacross/app-libs/*", + "bitacross/cli", + "bitacross/core/parentchain/block-import-dispatcher", + "bitacross/core/parentchain/block-importer", + "bitacross/core/parentchain/indirect-calls-executor", + "bitacross/core/parentchain/parentchain-crate", + "bitacross/core/direct-rpc-client", + "bitacross/core/direct-rpc-server", + "bitacross/core/offchain-worker-executor", + "bitacross/core-primitives/stf-executor", + "bitacross/core-primitives/top-pool", + "bitacross/core-primitives/top-pool-author", + "bitacross/core-primitives/enclave-api", + "bitacross/core-primitives/enclave-api/ffi", + "bitacross/service", + "bitacross/litentry/core/direct-call", + "bitacross/bitacross/core/*", +] + +exclude = [ + "common/core-primitives/sgx", + "common/core-primitives/substrate-sgx", + "identity/sidechain/consensus", + + # enclave-runtime needs to have its own workspace root for patching + "identity/enclave-runtime", + "bitacross/enclave-runtime", +] + +[workspace.dependencies] + +aes = { version = "0.6.0" } +byteorder = { version = "1.4.2", default-features = false } +thiserror = { version = "1.0" } +env_logger = { version = "0.10.0" } +log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", version = "=3.6.4", default-features = false, features = ["derive"] } +arrayvec = { version = "0.7.1", default-features = false } +bit-vec = { version = "0.6", default-features = false } +hex = { version = "0.4", default-features = false, features = ["alloc"] } +hex-literal = { version = "0.4" } +blake2-rfc = { version = "0.2.18", default-features = false } +itertools = { version = "0.10.1", default-features = false } +base58 = { version = "0.2", default-features = false } +base64 = { version = "0.13", default-features = false, features = ["alloc"] } +chrono = { version = "0.4.19", default-features = false, features = ["alloc"] } +derive_more = { version = "0.99" } +futures = { version = "0.3" } +rustls = { version = "0.19" } +serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } +serde_derive = { version = "1.0", default-features = false } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +webpki = { version = "0.21" } +hash-db = { version = "0.15.2", default-features = false } +bitcoin = { version = "0.31.0", default-features = false } +rand = { version = "0.7" } +ring = { version = "0.16.20", default-features = false } +scale-info = { version = "=2.11.0", default-features = false, features = ["derive"] } +secp256k1 = { version = "0.28.0", default-features = false } +ofb = { version = "0.4.0" } +lazy_static = { version = "1.1.0", features = ["spin_no_std"] } +threadpool = { version = "1.8.0" } +k256 = { version = "0.13.3", default-features = false } +ethabi = { version = "18.0.0", default-features = false } +evm = { version = "0.41.1", default-features = false, features = ["with-codec"] } +http = { version = "0.2" } +rust_decimal = { version = "1.35.0", default-features = false } +ss58-registry = { version = "1.40", default-features = false } +rust-base58 = { version = "0.0.4" } +primitive-types = { version = "0.12.1", default-features = false } +libsecp256k1 = { version = "0.7.0", default-features = false } +postcard = { version = "0.7.2", default-features = false, features = ["alloc"] } +jsonrpc-core = { version = "18" } +linked-hash-map = { version = "0.5.2" } +parity-util-mem = { version = "0.12.0", default-features = false } +mio = { version = "0.6.14" } +tungstenite = { version = "0.15.0" } +yasna = { version = "0.4" } +musig2 = { git = "https://github.com/kziemianek/musig2", branch = "master", features = ["k256"] } +rlp = { version = "0.5", default-features = false } +sha3 = { version = "0.10", default-features = false } + +url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } +substrate-api-client = { git = "https://github.com/scs/substrate-api-client", branch = "polkadot-v0.9.42-tag-v0.14.0", default-features = false, features = ["sync-api"] } +substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } + +# substrate +finality-grandpa = { version = "0.16.0", default-features = false, features = ["derive-codec"] } +frame-metadata = { version = "15.1.0", features = ["v14"], default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +binary-merkle-tree = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } + +# SGX SDK +sgx_alloc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_crypto_helper = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master", default-features = false } +sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_rand = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tcrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tcrypto_helper = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tse = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tseal = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tunittest = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_ucrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_serialize = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_serialize_derive = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_serialize_derive_internals = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } + + +# SGX-ported crates +base64_sgx = { package = "base64", git = "https://github.com/mesalock-linux/rust-base64-sgx", rev = "sgx_1.1.3" } +chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx" } +thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } +num-bigint = { git = "https://github.com/mesalock-linux/num-bigint-sgx" } +rustls_sgx = { package = "rustls", git = "https://github.com/mesalock-linux/rustls", tag = "sgx_1.1.3" } +serde_json_sgx = { package = "serde_json", git = "https://github.com/mesalock-linux/serde-json-sgx", tag = "sgx_1.1.3", features = ["preserve_order"] } +webpki-roots = { git = "https://github.com/mesalock-linux/webpki-roots", branch = "mesalock_sgx" } +webpki_sgx = { package = "webpki", git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } +yasna_sgx = { package = "yasna", git = "https://github.com/mesalock-linux/yasna.rs-sgx", rev = "sgx_1.1.3", default-features = false, features = ["bit-vec", "num-bigint", "chrono", "mesalock_sgx"] } +rand-sgx = { package = "rand", git = "https://github.com/mesalock-linux/rand-sgx", tag = "sgx_1.1.3", features = ["sgx_tstd"] } +rust-base58-sgx = { package = "rust-base58", git = "https://github.com/mesalock-linux/rust-base58-sgx", features = ["mesalock_sgx"] } +linked-hash-map_sgx = { package = "linked-hash-map", git = "https://github.com/mesalock-linux/linked-hash-map-sgx" } +mio_sgx = { package = "mio", git = "https://github.com/mesalock-linux/mio-sgx", tag = "sgx_1.1.3" } +futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx" } +threadpool_sgx = { package = "threadpool", git = "https://github.com/mesalock-linux/rust-threadpool-sgx", tag = "sgx_1.1.3" } +rust-base58_sgx = { package = "rust-base58", git = "https://github.com/mesalock-linux/rust-base58-sgx", rev = "sgx_1.1.3", default-features = false, features = ["mesalock_sgx"] } +musig2_sgx = { package = "musig2", git = "https://github.com/kailai-wang/musig2", branch = "use-sha2-0.8", features = ["k256"] } + +# Integritee patched libs +jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false } +httparse = { git = "https://github.com/integritee-network/httparse-sgx", branch = "sgx-experimental", default-features = false } +http_req = { git = "https://github.com/integritee-network/http_req", branch = "master", features = ["rust-tls"] } +http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx", branch = "sgx-experimental" } +http_req-sgx = { package = "http_req", git = "https://github.com/integritee-network/http_req", default-features = false, features = ["rust-tls", "sgx"] } +rcgen = { git = "https://github.com/integritee-network/rcgen", default-features = false } +mio-extras = { git = "https://github.com/integritee-network/mio-extras-sgx", rev = "963234b", default-features = false } +tungstenite_sgx = { package = "tungstenite", git = "https://github.com/integritee-network/tungstenite-rs-sgx", branch = "sgx-experimental", features = ["rustls-tls-webpki-roots"] } + +# local +itc-parentchain-light-client = { path = "common/core/parentchain/light-client", default-features = false } +itc-parentchain-test = { path = "common/core/parentchain/test", default-features = false } +itc-rest-client = { path = "common/core/rest-client", default-features = false } +itc-rpc-client = { path = "common/core/rpc-client" } +itc-tls-websocket-server = { path = "common/core/tls-websocket-server", default-features = false } + +itp-attestation-handler = { path = "common/core-primitives/attestation-handler", default-features = false } +itp-import-queue = { path = "common/core-primitives/import-queue", default-features = false } +itp-storage = { path = "common/core-primitives/storage", default-features = false } +itp-types = { path = "common/core-primitives/types", default-features = false } +itp-utils = { path = "common/core-primitives/utils", default-features = false } +itp-sgx-crypto = { path = "common/core-primitives/sgx/crypto", default-features = false } +itp-sgx-io = { path = "common/core-primitives/sgx/io", default-features = false } +itp-sgx-temp-dir = { path = "common/core-primitives/sgx/temp-dir", default-features = false } +itp-sgx-externalities = { path = "common/core-primitives/substrate-sgx/externalities", default-features = false } +itp-stf-primitives = { path = "common/core-primitives/stf-primitives", default-features = false } +itp-sgx-runtime-primitives = { path = "common/core-primitives/sgx-runtime-primitives", default-features = false } +itp-time-utils = { path = "common/core-primitives/time-utils", default-features = false } +itp-settings = { path = "common/core-primitives/settings" } +itp-ocall-api = { path = "common/core-primitives/ocall-api", default-features = false } +itp-binary-merkle-tree = { path = "common/core-primitives/binary-merkle-tree", default-features = false } +itp-component-container = { path = "common/core-primitives/component-container", default-features = false } +itp-rpc = { path = "common/core-primitives/rpc", default-features = false } +itp-hashing = { path = "common/core-primitives/hashing", default-features = false } +itp-enclave-metrics = { path = "common/core-primitives/enclave-metrics", default-features = false } +itp-extrinsics-factory = { path = "common/core-primitives/extrinsics-factory", default-features = false } +itp-nonce-cache = { path = "common/core-primitives/nonce-cache", default-features = false } +itp-node-api = { path = "common/core-primitives/node-api", default-features = false } +itp-api-client-extensions = { path = "common/core-primitives/node-api/api-client-extensions" } +itp-api-client-types = { path = "common/core-primitives/node-api/api-client-types", default-features = false } +itp-node-api-factory = { path = "common/core-primitives/node-api/factory" } +itp-node-api-metadata = { path = "common/core-primitives/node-api/metadata", default-features = false } +itp-node-api-metadata-provider = { path = "common/core-primitives/node-api/metadata-provider", default-features = false } +itp-networking-utils = { path = "common/core-primitives/networking-utils", default-features = false } +itp-primitives-cache = { path = "common/core-primitives/primitives-cache", default-features = false } +itp-stf-interface = { path = "common/core-primitives/stf-interface", default-features = false } +itp-stf-state-handler = { path = "common/core-primitives/stf-state-handler", default-features = false } +itp-stf-state-observer = { path = "common/core-primitives/stf-state-observer", default-features = false } +itp-test = { path = "common/core-primitives/test", default-features = false } + +# litentry +litentry-primitives = { path = "common/litentry/primitives", default-features = false } +litentry-worker-macros = { path = "common/litentry/macros" } +pallet-identity-management-tee = { path = "common/litentry/pallets/identity-management", default-features = false } +lc-teebag-storage = { path = "common/litentry/core/teebag-storage", default-features = false } +lc-parachain-extrinsic-task-sender = { path = "common/litentry/core/parachain-extrinsic-task/sender", default-features = false } +lc-parachain-extrinsic-task-receiver = { path = "common/litentry/core/parachain-extrinsic-task/receiver", default-features = false } +litentry-hex-utils = { path = "../common/utils/hex", default-features = false } +litentry-macros = { path = "../common/primitives/core/macros" } + +pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } +pallet-parachain-staking = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } +parentchain-primitives = { package = "core-primitives", git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } + +# identity +lc-assertion-build = { path = "identity/litentry/core/assertion-build", default-features = false } +lc-assertion-build-v2 = { path = "identity/litentry/core/assertion-build-v2", default-features = false } +lc-common = { path = "identity/litentry/core/common", default-features = false } +lc-credentials = { path = "identity/litentry/core/credentials", default-features = false } +lc-credentials-v2 = { path = "identity/litentry/core/credentials-v2", default-features = false } +lc-data-providers = { path = "identity/litentry/core/data-providers", default-features = false } +lc-dynamic-assertion = { path = "identity/litentry/core/dynamic-assertion", default-features = false } +lc-evm-dynamic-assertions = { path = "identity/litentry/core/evm-dynamic-assertions", default-features = false } +lc-identity-verification = { path = "identity/litentry/core/identity-verification", default-features = false } +lc-mock-server = { path = "identity/litentry/core/mock-server" } +lc-service = { path = "identity/litentry/core/service", default-features = false } +lc-stf-task-sender = { path = "identity/litentry/core/stf-task/sender", default-features = false } +lc-stf-task-receiver = { path = "identity/litentry/core/stf-task/receiver", default-features = false } +lc-vc-task-sender = { path = "identity/litentry/core/vc-task/sender", default-features = false } +lc-vc-task-receiver = { path = "identity/litentry/core/vc-task/receiver", default-features = false } + +itc-peer-top-broadcaster = { path = "identity/core/peer-top-broadcaster", default-features = false } +itc-rpc-server = { path = "identity/core/rpc-server", default-features = false } + +its-block-composer = { path = "identity/sidechain/block-composer", default-features = false } +its-block-verification = { path = "identity/sidechain/block-verification", default-features = false } +its-consensus-common = { path = "identity/sidechain/consensus/common", default-features = false } +its-consensus-aura = { path = "identity/sidechain/consensus/aura", default-features = false } +its-consensus-slots = { path = "identity/sidechain/consensus/slots", default-features = false } +fork-tree = { path = "identity/sidechain/fork-tree", default-features = false } +its-peer-fetch = { path = "identity/sidechain/peer-fetch", default-features = false } +its-primitives = { path = "identity/sidechain/primitives", default-features = false, features = ["full_crypto"] } +its-rpc-handler = { path = "identity/sidechain/rpc-handler", default-features = false } +its-sidechain = { path = "identity/sidechain/sidechain-crate", default-features = false } +its-state = { path = "identity/sidechain/state", default-features = false } +its-storage = { path = "identity/sidechain/storage" } +its-test = { path = "identity/sidechain/test", default-features = false } +its-validateer-fetch = { path = "identity/sidechain/validateer-fetch", default-features = false } + +[patch."https://github.com/apache/teaclave-sgx-sdk.git"] +sgx_alloc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_crypto_helper = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_rand = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tcrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_ucrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } diff --git a/tee-worker/bitacross/Cargo.lock b/tee-worker/bitacross/Cargo.lock deleted file mode 100644 index cd04f0851a..0000000000 --- a/tee-worker/bitacross/Cargo.lock +++ /dev/null @@ -1,9183 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex 1.9.5", -] - -[[package]] -name = "ac-compose-macros" -version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" -dependencies = [ - "ac-primitives", - "log 0.4.20", - "maybe-async", -] - -[[package]] -name = "ac-node-api" -version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" -dependencies = [ - "ac-primitives", - "bitvec", - "derive_more", - "either", - "frame-metadata", - "hex", - "log 0.4.20", - "parity-scale-codec", - "scale-bits", - "scale-decode", - "scale-encode", - "scale-info", - "serde 1.0.193", - "serde_json 1.0.103", - "sp-application-crypto", - "sp-core", - "sp-runtime", - "sp-runtime-interface", -] - -[[package]] -name = "ac-primitives" -version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" -dependencies = [ - "frame-system", - "impl-serde", - "pallet-assets", - "pallet-balances", - "parity-scale-codec", - "primitive-types", - "scale-info", - "serde 1.0.193", - "serde_json 1.0.103", - "sp-application-crypto", - "sp-core", - "sp-core-hashing", - "sp-runtime", - "sp-runtime-interface", - "sp-staking", - "sp-version", - "sp-weights", -] - -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli 0.26.2", -] - -[[package]] -name = "addr2line" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" -dependencies = [ - "gimli 0.27.3", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.10", - "once_cell 1.19.0", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if 1.0.0", - "getrandom 0.2.10", - "once_cell 1.19.0", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" -dependencies = [ - "memchr 2.6.3", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "anyhow" -version = "1.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" - -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "array-bytes" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" - -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "async-trait" -version = "0.1.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "auto_impl" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" -dependencies = [ - "addr2line 0.20.0", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object 0.31.1", - "rustc-demangle", -] - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base58" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" - -[[package]] -name = "base64" -version = "0.13.0" -source = "git+https://github.com/mesalock-linux/rust-base64-sgx?tag=sgx_1.1.3#dc7389e10817b078f289386b3b6a852ab6c4c021" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "base64" -version = "0.13.0" -source = "git+https://github.com/mesalock-linux/rust-base64-sgx?rev=sgx_1.1.3#dc7389e10817b078f289386b3b6a852ab6c4c021" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "base64" -version = "0.13.0" -source = "git+https://github.com/mesalock-linux/rust-base64-sgx#dc7389e10817b078f289386b3b6a852ab6c4c021" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bc-enclave-registry" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "itp-settings", - "itp-sgx-io", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-std", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "bc-musig2-ceremony" -version = "0.1.0" -dependencies = [ - "itp-sgx-crypto", - "k256", - "litentry-primitives", - "log 0.4.20", - "musig2 0.0.8 (git+https://github.com/kziemianek/musig2.git?branch=master)", - "musig2 0.0.8 (git+https://github.com/kailai-wang/musig2.git?branch=use-sha2-0.8)", - "parity-scale-codec", - "rand 0.8.5", - "sgx_rand", - "sgx_tstd", - "signature 2.1.0", -] - -[[package]] -name = "bc-musig2-event" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-musig2-ceremony", - "itc-direct-rpc-client", - "itc-direct-rpc-server", - "itp-ocall-api", - "itp-rpc", - "itp-sgx-crypto", - "itp-types", - "itp-utils", - "lc-direct-call", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "rand 0.8.5", - "sgx_rand", - "sgx_tstd", - "sp-core", - "threadpool 1.8.0", - "threadpool 1.8.1", -] - -[[package]] -name = "bc-relayer-registry" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "itp-settings", - "itp-sgx-io", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-std", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "bc-signer-registry" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "itp-settings", - "itp-sgx-io", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-std", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "bc-task-processor" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-musig2-ceremony", - "bc-musig2-event", - "bc-relayer-registry", - "bc-signer-registry", - "bc-task-sender", - "frame-support", - "futures 0.3.8", - "ita-stf", - "itc-direct-rpc-client", - "itc-direct-rpc-server", - "itp-enclave-metrics", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-executor", - "itp-stf-state-handler", - "lc-direct-call", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_crypto_helper", - "sgx_tstd", - "sp-core", - "thiserror 1.0.44", - "thiserror 1.0.9", - "threadpool 1.8.0", - "threadpool 1.8.1", -] - -[[package]] -name = "bc-task-sender" -version = "0.1.0" -dependencies = [ - "futures 0.3.28", - "futures 0.3.8", - "lazy_static", - "litentry-primitives", - "parity-scale-codec", - "sgx_tstd", -] - -[[package]] -name = "bech32" -version = "0.10.0-beta" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" - -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "binary-merkle-tree" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "hash-db 0.16.0", - "log 0.4.20", -] - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - -[[package]] -name = "bitacross-cli" -version = "0.0.1" -dependencies = [ - "base58", - "bc-musig2-ceremony", - "chrono 0.4.26", - "clap 4.1.0", - "env_logger", - "hdrhistogram", - "hex", - "ita-parentchain-interface", - "ita-stf", - "itc-rpc-client", - "itp-node-api", - "itp-rpc", - "itp-sgx-crypto", - "itp-stf-primitives", - "itp-types", - "itp-utils", - "lc-direct-call", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "rand 0.8.5", - "rayon", - "regex 1.9.5", - "reqwest", - "serde 1.0.193", - "serde_json 1.0.103", - "sgx_crypto_helper", - "sp-application-crypto", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "substrate-api-client", - "substrate-client-keystore", - "thiserror 1.0.44", - "urlencoding", -] - -[[package]] -name = "bitacross-worker" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "base58", - "clap 2.34.0", - "config", - "dirs", - "env_logger", - "frame-support", - "futures 0.3.28", - "hex", - "humantime", - "ipfs-api", - "ita-parentchain-interface", - "itc-parentchain", - "itc-parentchain-test", - "itc-rest-client", - "itc-rpc-client", - "itp-api-client-types", - "itp-enclave-api", - "itp-enclave-metrics", - "itp-node-api", - "itp-settings", - "itp-sgx-crypto", - "itp-stf-interface", - "itp-storage", - "itp-time-utils", - "itp-types", - "itp-utils", - "jsonrpsee", - "lazy_static", - "litentry-primitives", - "log 0.4.20", - "mockall", - "parity-scale-codec", - "parking_lot 0.12.1", - "parse_duration", - "prometheus", - "rayon", - "regex 1.9.5", - "scale-info", - "serde 1.0.193", - "serde_derive 1.0.193", - "serde_json 1.0.103", - "sgx_crypto_helper", - "sgx_types", - "sp-consensus-grandpa", - "sp-core", - "sp-keyring", - "sp-runtime", - "substrate-api-client", - "thiserror 1.0.44", - "tokio", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "warp", -] - -[[package]] -name = "bitcoin" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5973a027b341b462105675962214dfe3c938ad9afd395d84b28602608bdcec7b" -dependencies = [ - "bech32", - "bitcoin-internals", - "bitcoin_hashes", - "core2", - "hex-conservative", - "hex_lit", - "secp256k1 0.28.0", -] - -[[package]] -name = "bitcoin-internals" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" - -[[package]] -name = "bitcoin_hashes" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" -dependencies = [ - "bitcoin-internals", - "core2", - "hex-conservative", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "blake2b_simd" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" -dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder 1.4.3", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bounded-collections" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" -dependencies = [ - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "bumpalo" -version = "3.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "bytemuck" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "git+https://github.com/mesalock-linux/byteorder-sgx?tag=sgx_1.1.3#325f392dcd294109eb05f0a3c45e4141514c7784" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder 1.4.3", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bytes" -version = "1.0.1" -source = "git+https://github.com/integritee-network/bytes-sgx?branch=sgx-experimental#62ed3082be2e23cb9bc8cc7ee9983a523de69292" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" - -[[package]] -name = "cargo_toml" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dc9f7a067415ab5058020f04c60ec7b557084dbec0e021217bbabc7a8d38d14" -dependencies = [ - "serde 1.0.193", - "toml 0.8.2", -] - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-expr" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" -dependencies = [ - "smallvec 1.11.0", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.11" -source = "git+https://github.com/mesalock-linux/chrono-sgx#f964ae7f5f65bd2c9cd6f44a067e7980afc08ca0" -dependencies = [ - "num-integer 0.1.41", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "chrono" -version = "0.4.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits 0.2.16", - "serde 1.0.193", - "time", - "wasm-bindgen", - "winapi 0.3.9", -] - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", - "yaml-rust 0.3.5", -] - -[[package]] -name = "clap" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa91278560fc226a5d9d736cc21e485ff9aad47d26b8ffe1f54cba868b684b9f" -dependencies = [ - "bitflags 1.3.2", - "clap_derive", - "clap_lex", - "is-terminal", - "once_cell 1.19.0", - "strsim 0.10.0", - "termcolor", -] - -[[package]] -name = "clap_derive" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "clap_lex" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" -dependencies = [ - "os_str_bytes", -] - -[[package]] -name = "common-multipart-rfc7578" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d0a7a42b9c13f2b2a1a7e64b949a19bcb56a49b190076e60261001ceaa5304" -dependencies = [ - "bytes 1.4.0", - "futures 0.3.28", - "http 0.2.9", - "mime", - "mime_guess", - "rand 0.8.5", - "thiserror 1.0.44", -] - -[[package]] -name = "config" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" -dependencies = [ - "async-trait", - "json5", - "lazy_static", - "nom", - "pathdiff", - "ron", - "rust-ini", - "serde 1.0.193", - "serde_json 1.0.103", - "toml 0.5.11", - "yaml-rust 0.4.5", -] - -[[package]] -name = "const-oid" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" - -[[package]] -name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "core-primitives" -version = "0.1.0" -source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#ea133d42f915d6e3cbbc51304f534d0b9f42e5d3" -dependencies = [ - "base58", - "frame-support", - "litentry-hex-utils 0.1.0 (git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19)", - "litentry-macros 0.1.0 (git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19)", - "litentry-proc-macros", - "pallet-evm", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", - "strum 0.26.1", - "strum_macros 0.26.1", -] - -[[package]] -name = "core2" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239fa3ae9b63c2dc74bd3fa852d4792b8b305ae64eeede946265b6af62f1fff3" -dependencies = [ - "memchr 2.6.3", -] - -[[package]] -name = "cpp_demangle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "cranelift-entity" -version = "0.93.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset 0.9.0", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array 0.14.7", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array 0.14.7", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crypto-mac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" -dependencies = [ - "generic-array 0.14.7", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct 0.6.1", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" -dependencies = [ - "byteorder 1.4.3", - "digest 0.8.1", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder 1.4.3", - "digest 0.9.0", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv 1.0.7", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "data-encoding" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "der_derive", - "flagset", -] - -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "der_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef71ddb5b3a1f53dee24817c8f70dfa1cb29e804c18d88c228d4bc9c86ee3b9" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive-syn-parse" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "difflib" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "const-oid", - "crypto-common", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "dirs" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - -[[package]] -name = "dlv-list" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" - -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - -[[package]] -name = "dyn-clonable" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" -dependencies = [ - "dyn-clonable-impl", - "dyn-clone", -] - -[[package]] -name = "dyn-clonable-impl" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "dyn-clone" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" - -[[package]] -name = "ecdsa" -version = "0.16.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" -dependencies = [ - "der 0.7.8", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature 2.1.0", - "spki 0.7.2", -] - -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "signature 1.6.4", -] - -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek 3.2.0", - "ed25519", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", - "hex", - "rand_core 0.6.4", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest 0.10.7", - "ff", - "generic-array 0.14.7", - "group", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log 0.4.20", - "regex 1.9.5", - "termcolor", -] - -[[package]] -name = "environmental" -version = "1.1.3" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "environmental" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89fb87a9e103f71b903b80b670200b54cc67a07578f070681f1fffb7396fb7" -dependencies = [ - "bytes 1.4.0", - "ethereum-types", - "hash-db 0.15.2", - "hash256-std-hasher", - "parity-scale-codec", - "rlp", - "scale-info", - "serde 1.0.193", - "sha3", - "triehash", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "evm" -version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" -dependencies = [ - "auto_impl", - "environmental 1.1.4", - "ethereum", - "evm-core", - "evm-gasometer", - "evm-runtime", - "log 0.4.20", - "parity-scale-codec", - "primitive-types", - "rlp", - "scale-info", - "serde 1.0.193", - "sha3", -] - -[[package]] -name = "evm-core" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" -dependencies = [ - "parity-scale-codec", - "primitive-types", - "scale-info", - "serde 1.0.193", -] - -[[package]] -name = "evm-gasometer" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" -dependencies = [ - "environmental 1.1.4", - "evm-core", - "evm-runtime", - "primitive-types", -] - -[[package]] -name = "evm-runtime" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" -dependencies = [ - "auto_impl", - "environmental 1.1.4", - "evm-core", - "primitive-types", - "sha3", -] - -[[package]] -name = "expander" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" -dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastrand" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core 0.6.4", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "finality-grandpa" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" -dependencies = [ - "either", - "futures 0.3.28", - "futures-timer", - "log 0.4.20", - "num-traits 0.2.16", - "parity-scale-codec", - "parking_lot 0.12.1", - "scale-info", -] - -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "byteorder 1.4.3", - "rand 0.8.5", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "flagset" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" - -[[package]] -name = "flate2" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "float-cmp" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "git+https://github.com/mesalock-linux/rust-fnv-sgx#c3bd6153c1403c1fa32fa54be5544d91f5efb017" -dependencies = [ - "hashbrown 0.3.1", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" -dependencies = [ - "percent-encoding 2.3.1 (git+https://github.com/domenukk/rust-url?branch=no_std)", -] - -[[package]] -name = "fp-account" -version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" -dependencies = [ - "hex", - "impl-serde", - "libsecp256k1", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-runtime-interface", - "sp-std", -] - -[[package]] -name = "fp-evm" -version = "3.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" -dependencies = [ - "evm", - "frame-support", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "fragile" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" - -[[package]] -name = "frame-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "frame-support-procedural", - "frame-system", - "linregress", - "log 0.4.20", - "parity-scale-codec", - "paste", - "scale-info", - "serde 1.0.193", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "static_assertions", -] - -[[package]] -name = "frame-executive" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "frame-metadata" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" -dependencies = [ - "cfg-if 1.0.0", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", -] - -[[package]] -name = "frame-support" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "bitflags 1.3.2", - "environmental 1.1.4", - "frame-metadata", - "frame-support-procedural", - "impl-trait-for-tuples", - "k256", - "log 0.4.20", - "once_cell 1.19.0", - "parity-scale-codec", - "paste", - "scale-info", - "serde 1.0.193", - "smallvec 1.11.0", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-core-hashing-proc-macro", - "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-staking", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-weights", - "tt-call", -] - -[[package]] -name = "frame-support-procedural" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "Inflector", - "cfg-expr", - "derive-syn-parse", - "frame-support-procedural-tools", - "itertools 0.10.5", - "proc-macro-warning", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "frame-support-procedural-tools" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support-procedural-tools-derive", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "frame-support-procedural-tools-derive" -version = "3.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "frame-system" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", - "sp-version", - "sp-weights", -] - -[[package]] -name = "fs-err" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags 1.3.2", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "futures-channel 0.3.8", - "futures-core 0.3.8", - "futures-executor 0.3.8", - "futures-io 0.3.8", - "futures-sink 0.3.8", - "futures-task 0.3.8", - "futures-util 0.3.8", - "sgx_tstd", -] - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel 0.3.28", - "futures-core 0.3.28", - "futures-executor 0.3.28", - "futures-io 0.3.28", - "futures-sink 0.3.28", - "futures-task 0.3.28", - "futures-util 0.3.28", -] - -[[package]] -name = "futures-channel" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "futures-core 0.3.8", - "futures-sink 0.3.8", - "sgx_tstd", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core 0.3.28", - "futures-sink 0.3.28", -] - -[[package]] -name = "futures-core" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "futures-core 0.3.8", - "futures-task 0.3.8", - "futures-util 0.3.8", - "sgx_tstd", -] - -[[package]] -name = "futures-executor" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" -dependencies = [ - "futures-core 0.3.28", - "futures-task 0.3.28", - "futures-util 0.3.28", - "num_cpus", -] - -[[package]] -name = "futures-io" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-macro" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "futures-sink" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx)", - "sgx_tstd", -] - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - -[[package]] -name = "futures-util" -version = "0.3.8" -source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d61327a067b2f608d6940a36444" -dependencies = [ - "futures-channel 0.3.8", - "futures-core 0.3.8", - "futures-io 0.3.8", - "futures-macro 0.3.8", - "futures-sink 0.3.8", - "futures-task 0.3.8", - "memchr 2.2.1", - "pin-project-lite", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "sgx_tstd", - "slab 0.4.2", -] - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-channel 0.3.28", - "futures-core 0.3.28", - "futures-io 0.3.28", - "futures-macro 0.3.28", - "futures-sink 0.3.28", - "futures-task 0.3.28", - "memchr 2.6.3", - "pin-project-lite", - "pin-utils", - "slab 0.4.8", -] - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "git+https://github.com/mesalock-linux/getrandom-sgx#0aa9cc20c7dea713ccaac2c44430d625a395ebae" -dependencies = [ - "cfg-if 0.1.10", - "sgx_libc", - "sgx_trts", - "sgx_tstd", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" -dependencies = [ - "fallible-iterator", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "h2" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" -dependencies = [ - "bytes 1.4.0", - "fnv 1.0.7", - "futures-core 0.3.28", - "futures-sink 0.3.28", - "futures-util 0.3.28", - "http 0.2.9", - "indexmap 1.9.3", - "slab 0.4.8", - "tokio", - "tokio-util 0.7.8", - "tracing", -] - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash-db" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.6", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", -] - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - -[[package]] -name = "hashbrown_tstd" -version = "0.12.0" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" - -[[package]] -name = "hdrhistogram" -version = "7.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f19b9f54f7c7f55e31401bb647626ce0cf0f67b0004982ce815b3ee72a02aa8" -dependencies = [ - "base64 0.13.1", - "byteorder 1.4.3", - "crossbeam-channel", - "flate2", - "nom", - "num-traits 0.2.16", -] - -[[package]] -name = "headers" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" -dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", - "bytes 1.4.0", - "headers-core", - "http 0.2.9", - "httpdate", - "mime", - "sha1 0.10.5", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http 0.2.9", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-conservative" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" -dependencies = [ - "core2", -] - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hex_lit" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" - -[[package]] -name = "hmac" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" -dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac 0.11.0", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "hmac-drbg" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" -dependencies = [ - "digest 0.9.0", - "generic-array 0.14.7", - "hmac 0.8.1", -] - -[[package]] -name = "http" -version = "0.2.1" -source = "git+https://github.com/integritee-network/http-sgx.git?branch=sgx-experimental#307b5421fb7a489a114bede0dc05c8d32b804f49" -dependencies = [ - "bytes 1.0.1", - "fnv 1.0.6", - "itoa 0.4.5", - "sgx_tstd", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes 1.4.0", - "fnv 1.0.7", - "itoa 1.0.9", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes 1.4.0", - "http 0.2.9", - "pin-project-lite", -] - -[[package]] -name = "http_req" -version = "0.8.1" -source = "git+https://github.com/integritee-network/http_req?branch=master#3723e88235f2b29bc1a31835853b072ffd0455fd" -dependencies = [ - "log 0.4.20", - "rustls 0.19.1", - "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki-roots 0.21.1", -] - -[[package]] -name = "http_req" -version = "0.8.1" -source = "git+https://github.com/integritee-network/http_req#3723e88235f2b29bc1a31835853b072ffd0455fd" -dependencies = [ - "log 0.4.20", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx)", - "sgx_tstd", - "unicase 2.6.0 (git+https://github.com/mesalock-linux/unicase-sgx)", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", - "webpki-roots 0.21.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", -] - -[[package]] -name = "httparse" -version = "1.4.1" -source = "git+https://github.com/integritee-network/httparse-sgx?branch=sgx-experimental#cc97e4b34d2c44a1e3df5bdebef446b9771f5cc3" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes 1.4.0", - "futures-channel 0.3.28", - "futures-core 0.3.28", - "futures-util 0.3.28", - "h2", - "http 0.2.9", - "http-body", - "httparse 1.8.0", - "httpdate", - "itoa 1.0.9", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-multipart-rfc7578" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538ce6aeb81f7cd0d547a42435944d2283714a3f696630318bc47bd839fcfc9" -dependencies = [ - "bytes 1.4.0", - "common-multipart-rfc7578", - "futures 0.3.28", - "http 0.2.9", - "hyper", -] - -[[package]] -name = "hyper-rustls" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" -dependencies = [ - "ct-logs", - "futures-util 0.3.28", - "hyper", - "log 0.4.20", - "rustls 0.19.1", - "rustls-native-certs", - "tokio", - "tokio-rustls", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes 1.4.0", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.2.0" -source = "git+https://github.com/mesalock-linux/rust-url-sgx?tag=sgx_1.1.3#23832f3191456c2d4a0faab10952e1747be58ca8" -dependencies = [ - "matches", - "sgx_tstd", - "unicode-bidi 0.3.4", - "unicode-normalization 0.1.12", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi 0.3.13", - "unicode-normalization 0.1.22", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" -dependencies = [ - "unicode-bidi 0.3.13", - "unicode-normalization 0.1.22", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.6.1" -source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" -dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.9.1", - "sgx_tstd", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.12.3", - "serde 1.0.193", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.2", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" -dependencies = [ - "sgx_libc", -] - -[[package]] -name = "ipfs-api" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3824538e42e84c792988098df4ad5a35b47be98b19e31454e09f4e322f00fc" -dependencies = [ - "bytes 1.4.0", - "dirs", - "failure", - "futures 0.3.28", - "http 0.2.9", - "hyper", - "hyper-multipart-rfc7578", - "hyper-tls", - "parity-multiaddr", - "serde 1.0.193", - "serde_json 1.0.103", - "serde_urlencoded", - "tokio", - "tokio-util 0.6.10", - "tracing", - "typed-builder", - "walkdir", -] - -[[package]] -name = "ipnet" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.4", - "windows-sys 0.48.0", -] - -[[package]] -name = "ita-parentchain-interface" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-relayer-registry", - "bc-signer-registry", - "env_logger", - "ita-sgx-runtime", - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-test", - "itp-api-client-types", - "itp-node-api", - "itp-sgx-crypto", - "itp-stf-executor", - "itp-stf-primitives", - "itp-test", - "itp-top-pool-author", - "itp-types", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "sp-std", - "substrate-api-client", -] - -[[package]] -name = "ita-sgx-runtime" -version = "0.1.0" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "itp-sgx-runtime-primitives", - "pallet-balances", - "pallet-parentchain", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "ita-stf" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "hex", - "hex-literal", - "ita-sgx-runtime", - "itp-hashing", - "itp-node-api", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-storage", - "itp-types", - "itp-utils", - "litentry-macros 0.1.0", - "litentry-primitives", - "log 0.4.20", - "pallet-balances", - "pallet-parentchain", - "pallet-sudo", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-io 7.0.0", - "sp-keyring", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "itc-direct-rpc-client" -version = "0.1.0" -dependencies = [ - "itp-rpc", - "log 0.4.20", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", - "rustls 0.19.1", - "serde_json 1.0.103", - "sgx_tstd", - "tungstenite 0.14.0", - "tungstenite 0.15.0", - "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "itc-direct-rpc-server" -version = "0.1.0" -dependencies = [ - "itc-tls-websocket-server", - "itp-rpc", - "itp-types", - "itp-utils", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "log 0.4.20", - "parity-scale-codec", - "serde_json 1.0.103", - "sgx_tstd", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-offchain-worker-executor" -version = "0.1.0" -dependencies = [ - "itc-parentchain-light-client", - "itp-extrinsics-factory", - "itp-sgx-externalities", - "itp-stf-executor", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool-author", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-parentchain" -version = "0.1.0" -dependencies = [ - "itc-parentchain-block-import-dispatcher", - "itc-parentchain-block-importer", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-types", - "parity-scale-codec", - "sp-runtime", -] - -[[package]] -name = "itc-parentchain-block-import-dispatcher" -version = "0.1.0" -dependencies = [ - "itc-parentchain-block-importer", - "itp-import-queue", - "log 0.4.20", - "sgx_tstd", - "sgx_types", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-parentchain-block-importer" -version = "0.1.0" -dependencies = [ - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-enclave-metrics", - "itp-extrinsics-factory", - "itp-ocall-api", - "itp-stf-executor", - "itp-stf-interface", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-parentchain-indirect-calls-executor" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-relayer-registry", - "bc-signer-registry", - "binary-merkle-tree", - "bs58", - "env_logger", - "futures 0.3.28", - "futures 0.3.8", - "itc-parentchain-test", - "itp-api-client-types", - "itp-node-api", - "itp-sgx-crypto", - "itp-sgx-runtime-primitives", - "itp-stf-executor", - "itp-stf-primitives", - "itp-test", - "itp-top-pool-author", - "itp-types", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-parentchain-light-client" -version = "0.1.0" -dependencies = [ - "finality-grandpa", - "itc-parentchain-test", - "itp-ocall-api", - "itp-sgx-io", - "itp-sgx-temp-dir", - "itp-storage", - "itp-test", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-consensus-grandpa", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itc-parentchain-test" -version = "0.1.0" -dependencies = [ - "itp-types", - "sp-runtime", -] - -[[package]] -name = "itc-rest-client" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "http 0.2.1", - "http 0.2.9", - "http_req 0.8.1 (git+https://github.com/integritee-network/http_req?branch=master)", - "http_req 0.8.1 (git+https://github.com/integritee-network/http_req)", - "log 0.4.20", - "serde 1.0.193", - "serde_json 1.0.103", - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", - "url 2.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", -] - -[[package]] -name = "itc-rpc-client" -version = "0.1.0" -dependencies = [ - "base58", - "env_logger", - "frame-metadata", - "ita-stf", - "itc-tls-websocket-server", - "itp-api-client-types", - "itp-networking-utils", - "itp-rpc", - "itp-stf-primitives", - "itp-types", - "itp-utils", - "log 0.4.20", - "openssl", - "parity-scale-codec", - "parking_lot 0.12.1", - "rustls 0.19.1", - "serde_json 1.0.103", - "sgx_crypto_helper", - "thiserror 1.0.44", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ws", -] - -[[package]] -name = "itc-tls-websocket-server" -version = "0.1.0" -dependencies = [ - "bit-vec", - "chrono 0.4.26", - "env_logger", - "log 0.4.20", - "mio 0.6.21", - "mio 0.6.23", - "mio-extras 2.0.6 (git+https://github.com/integritee-network/mio-extras-sgx?rev=963234b)", - "rcgen", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx)", - "rustls 0.19.1", - "sgx_tstd", - "sp-core", - "thiserror 1.0.44", - "thiserror 1.0.9", - "tungstenite 0.14.0", - "tungstenite 0.15.0", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", - "yasna 0.3.1", - "yasna 0.4.0", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "git+https://github.com/mesalock-linux/itoa-sgx#295ee451f5ec74f25c299552b481beb445ea3eb7" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "itp-api-client-extensions" -version = "0.1.0" -dependencies = [ - "itp-api-client-types", - "itp-types", - "sp-consensus-grandpa", - "sp-runtime", - "substrate-api-client", -] - -[[package]] -name = "itp-api-client-types" -version = "0.1.0" -dependencies = [ - "itp-types", - "substrate-api-client", -] - -[[package]] -name = "itp-attestation-handler" -version = "0.8.0" -dependencies = [ - "arrayvec 0.7.4", - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx?rev=sgx_1.1.3)", - "base64 0.13.1", - "bit-vec", - "chrono 0.4.11", - "chrono 0.4.26", - "hex", - "httparse 1.4.1", - "itertools 0.10.5", - "itp-ocall-api", - "itp-settings", - "itp-sgx-crypto", - "itp-sgx-io", - "itp-time-utils", - "log 0.4.20", - "num-bigint 0.2.5", - "parity-scale-codec", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", - "rustls 0.19.1", - "serde_json 1.0.103", - "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", - "sgx_rand", - "sgx_tcrypto", - "sgx_tse", - "sgx_tstd", - "sgx_types", - "sp-core", - "thiserror 1.0.44", - "thiserror 1.0.9", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", - "webpki-roots 0.21.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", - "yasna 0.3.1", -] - -[[package]] -name = "itp-component-container" -version = "0.8.0" -dependencies = [ - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-enclave-api" -version = "0.1.0" -dependencies = [ - "frame-support", - "hex", - "itc-parentchain", - "itp-enclave-api-ffi", - "itp-settings", - "itp-sgx-crypto", - "itp-stf-interface", - "itp-storage", - "itp-types", - "log 0.4.20", - "pallet-teebag", - "parity-scale-codec", - "serde_json 1.0.103", - "sgx_crypto_helper", - "sgx_types", - "sgx_urts", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", -] - -[[package]] -name = "itp-enclave-api-ffi" -version = "0.1.0" -dependencies = [ - "sgx_types", -] - -[[package]] -name = "itp-enclave-metrics" -version = "0.1.0" -dependencies = [ - "parity-scale-codec", - "sgx_tstd", -] - -[[package]] -name = "itp-extrinsics-factory" -version = "0.1.0" -dependencies = [ - "itp-node-api", - "itp-nonce-cache", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "substrate-api-client", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-hashing" -version = "0.1.0" -dependencies = [ - "sp-core", -] - -[[package]] -name = "itp-import-queue" -version = "0.8.0" -dependencies = [ - "sgx_tstd", - "sgx_types", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-networking-utils" -version = "0.1.0" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "itp-node-api" -version = "0.1.0" -dependencies = [ - "itp-api-client-extensions", - "itp-api-client-types", - "itp-node-api-factory", - "itp-node-api-metadata", - "itp-node-api-metadata-provider", -] - -[[package]] -name = "itp-node-api-factory" -version = "0.1.0" -dependencies = [ - "itp-api-client-types", - "sp-core", - "thiserror 1.0.44", -] - -[[package]] -name = "itp-node-api-metadata" -version = "0.1.0" -dependencies = [ - "derive_more", - "itp-api-client-types", - "itp-stf-primitives", - "parity-scale-codec", - "sp-core", -] - -[[package]] -name = "itp-node-api-metadata-provider" -version = "0.1.0" -dependencies = [ - "itp-node-api-metadata", - "itp-stf-primitives", - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-nonce-cache" -version = "0.8.0" -dependencies = [ - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-ocall-api" -version = "0.1.0" -dependencies = [ - "derive_more", - "itp-storage", - "itp-types", - "parity-scale-codec", - "sgx_types", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "itp-primitives-cache" -version = "0.1.0" -dependencies = [ - "lazy_static", - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-rpc" -version = "0.1.0" -dependencies = [ - "itp-types", - "parity-scale-codec", - "serde 1.0.193", - "serde_json 1.0.103", - "sgx_tstd", -] - -[[package]] -name = "itp-settings" -version = "0.1.0" - -[[package]] -name = "itp-sgx-crypto" -version = "0.1.0" -dependencies = [ - "aes", - "derive_more", - "hex", - "itp-sgx-io", - "itp-sgx-temp-dir", - "k256", - "log 0.4.20", - "ofb", - "parity-scale-codec", - "secp256k1 0.29.0", - "serde_json 1.0.103", - "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", - "sgx_crypto_helper", - "sgx_rand", - "sgx_tstd", - "sgx_types", - "sp-core", -] - -[[package]] -name = "itp-sgx-externalities" -version = "0.1.0" -dependencies = [ - "derive_more", - "environmental 1.1.3", - "itp-hashing", - "itp-storage", - "log 0.4.20", - "parity-scale-codec", - "postcard", - "serde 1.0.193", - "sgx_tstd", - "sp-core", -] - -[[package]] -name = "itp-sgx-io" -version = "0.8.0" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "itp-sgx-runtime-primitives" -version = "0.1.0" -dependencies = [ - "frame-system", - "pallet-balances", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "itp-sgx-temp-dir" -version = "0.1.0" -dependencies = [ - "lazy_static", - "safe-lock", - "sgx_tstd", -] - -[[package]] -name = "itp-stf-executor" -version = "0.1.0" -dependencies = [ - "hex", - "itc-parentchain-test", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-stf-state-observer", - "itp-test", - "itp-time-utils", - "itp-top-pool", - "itp-top-pool-author", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-stf-interface" -version = "0.8.0" -dependencies = [ - "itp-node-api-metadata", - "itp-node-api-metadata-provider", - "itp-stf-primitives", - "itp-types", - "parity-scale-codec", -] - -[[package]] -name = "itp-stf-primitives" -version = "0.1.0" -dependencies = [ - "derive_more", - "itp-sgx-runtime-primitives", - "litentry-primitives", - "parity-scale-codec", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "itp-stf-state-handler" -version = "0.1.0" -dependencies = [ - "itp-hashing", - "itp-settings", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-sgx-io", - "itp-sgx-temp-dir", - "itp-stf-interface", - "itp-stf-state-observer", - "itp-time-utils", - "itp-types", - "log 0.4.20", - "parity-scale-codec", - "rust-base58 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-base58 0.0.4 (git+https://github.com/mesalock-linux/rust-base58-sgx?rev=sgx_1.1.3)", - "sgx_tstd", - "sgx_types", - "sp-core", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-stf-state-observer" -version = "0.1.0" -dependencies = [ - "itp-types", - "log 0.4.20", - "sgx_tstd", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-storage" -version = "0.1.0" -dependencies = [ - "derive_more", - "frame-metadata", - "frame-support", - "hash-db 0.15.2", - "itp-types", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "thiserror 1.0.44", - "thiserror 1.0.9", -] - -[[package]] -name = "itp-test" -version = "0.1.0" -dependencies = [ - "hex", - "itp-node-api", - "itp-node-api-metadata-provider", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-storage", - "itp-types", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "lc-teebag-storage", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "sgx_crypto_helper", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-io 7.0.0", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "itp-time-utils" -version = "0.1.0" -dependencies = [ - "chrono 0.4.11", - "chrono 0.4.26", - "sgx_tstd", -] - -[[package]] -name = "itp-top-pool" -version = "0.1.0" -dependencies = [ - "byteorder 1.4.3", - "derive_more", - "itc-direct-rpc-server", - "itp-stf-primitives", - "itp-test", - "itp-types", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "linked-hash-map 0.5.2", - "linked-hash-map 0.5.6", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "parity-util-mem", - "serde 1.0.193", - "sgx_tstd", - "sp-application-crypto", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "itp-top-pool-author" -version = "0.1.0" -dependencies = [ - "derive_more", - "futures 0.3.28", - "itp-sgx-crypto", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool", - "itp-types", - "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 18.0.0 (git+https://github.com/scs/jsonrpc?branch=no_std_v18)", - "lazy_static", - "log 0.4.20", - "parity-scale-codec", - "sgx_crypto_helper", - "sgx_tstd", - "sp-core", - "sp-keyring", - "sp-runtime", -] - -[[package]] -name = "itp-types" -version = "0.1.0" -dependencies = [ - "frame-system", - "itp-sgx-crypto", - "itp-sgx-runtime-primitives", - "itp-stf-primitives", - "itp-utils", - "litentry-primitives", - "pallet-balances", - "parity-scale-codec", - "serde 1.0.193", - "sp-core", - "sp-runtime", - "sp-std", - "substrate-api-client", -] - -[[package]] -name = "itp-utils" -version = "0.1.0" -dependencies = [ - "hex", - "litentry-hex-utils 0.1.0", - "parity-scale-codec", -] - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "json5" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" -dependencies = [ - "pest", - "pest_derive", - "serde 1.0.193", -] - -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures 0.3.28", - "futures-executor 0.3.28", - "futures-util 0.3.28", - "log 0.4.20", - "serde 1.0.193", - "serde_derive 1.0.193", - "serde_json 1.0.103", -] - -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "git+https://github.com/scs/jsonrpc?branch=no_std_v18#0faf53c491c3222b96242a973d902dd06e9b6674" -dependencies = [ - "futures 0.3.8", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "serde 1.0.118", - "serde_derive 1.0.118", - "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx)", -] - -[[package]] -name = "jsonrpsee" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316a89048d2ea5530ab5502aa31e1128f6429b524a37e4c0bc54903bcdf3d342" -dependencies = [ - "jsonrpsee-http-client", - "jsonrpsee-proc-macros", - "jsonrpsee-types", - "jsonrpsee-ws-client", - "jsonrpsee-ws-server", -] - -[[package]] -name = "jsonrpsee-http-client" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7275601ba6f9f6feaa82d3c66b51e34d190e75f1cf23d5c40f7801f3a7610a6" -dependencies = [ - "async-trait", - "fnv 1.0.7", - "hyper", - "hyper-rustls", - "jsonrpsee-types", - "jsonrpsee-utils", - "log 0.4.20", - "serde 1.0.193", - "serde_json 1.0.103", - "thiserror 1.0.44", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b4c85cfa6767333f3e5f3b2f2f765dad2727b0033ee270ae07c599bf43ed5ae" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "jsonrpsee-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cf7bd4e93b3b56e59131de7f24afbea871faf914e97bcdd942c86927ab0172" -dependencies = [ - "async-trait", - "beef", - "futures-channel 0.3.28", - "futures-util 0.3.28", - "hyper", - "log 0.4.20", - "serde 1.0.193", - "serde_json 1.0.103", - "soketto", - "thiserror 1.0.44", -] - -[[package]] -name = "jsonrpsee-utils" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47554ecaacb479285da68799d9b6afc258c32b332cc8b85829c6a9304ee98776" -dependencies = [ - "futures-channel 0.3.28", - "futures-util 0.3.28", - "hyper", - "jsonrpsee-types", - "log 0.4.20", - "parking_lot 0.11.2", - "rand 0.8.5", - "rustc-hash", - "serde 1.0.193", - "serde_json 1.0.103", - "thiserror 1.0.44", -] - -[[package]] -name = "jsonrpsee-ws-client" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ec51150965544e1a4468f372bdab8545243a1b045d4ab272023aac74c60de32" -dependencies = [ - "async-trait", - "fnv 1.0.7", - "futures 0.3.28", - "jsonrpsee-types", - "log 0.4.20", - "pin-project", - "rustls 0.19.1", - "rustls-native-certs", - "serde 1.0.193", - "serde_json 1.0.103", - "soketto", - "thiserror 1.0.44", - "tokio", - "tokio-rustls", - "tokio-util 0.6.10", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "jsonrpsee-ws-server" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b512c3c679a89d20f97802f69188a2d01f6234491b7513076e21e8424efccafe" -dependencies = [ - "futures-channel 0.3.28", - "futures-util 0.3.28", - "jsonrpsee-types", - "jsonrpsee-utils", - "log 0.4.20", - "rustc-hash", - "serde 1.0.193", - "serde_json 1.0.103", - "soketto", - "thiserror 1.0.44", - "tokio", - "tokio-stream", - "tokio-util 0.6.10", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if 1.0.0", - "ecdsa", - "elliptic-curve", - "once_cell 1.19.0", - "sha2 0.10.8", - "signature 2.1.0", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin 0.5.2", -] - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "lc-direct-call" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-musig2-ceremony", - "bc-relayer-registry", - "bc-signer-registry", - "hex", - "itp-sgx-crypto", - "itp-stf-primitives", - "k256", - "litentry-primitives", - "log 0.4.20", - "parity-scale-codec", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx_tstd", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", -] - -[[package]] -name = "lc-teebag-storage" -version = "0.1.0" -dependencies = [ - "itp-storage", - "itp-types", - "sp-std", -] - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "libm" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" - -[[package]] -name = "libsecp256k1" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" -dependencies = [ - "arrayref", - "base64 0.13.1", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", - "rand 0.8.5", - "serde 1.0.193", - "sha2 0.9.9", - "typenum", -] - -[[package]] -name = "libsecp256k1-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "libsecp256k1-gen-genmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "git+https://github.com/mesalock-linux/linked-hash-map-sgx#03e763f7c251c16e0b85e2fb058ba47be52f2a49" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linregress" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" -dependencies = [ - "nalgebra", -] - -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" - -[[package]] -name = "litentry-hex-utils" -version = "0.1.0" -dependencies = [ - "hex", -] - -[[package]] -name = "litentry-hex-utils" -version = "0.1.0" -source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#ea133d42f915d6e3cbbc51304f534d0b9f42e5d3" -dependencies = [ - "hex", -] - -[[package]] -name = "litentry-macros" -version = "0.1.0" - -[[package]] -name = "litentry-macros" -version = "0.1.0" -source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#ea133d42f915d6e3cbbc51304f534d0b9f42e5d3" - -[[package]] -name = "litentry-primitives" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "bitcoin", - "core-primitives", - "hex", - "itp-sgx-crypto", - "litentry-hex-utils 0.1.0", - "log 0.4.20", - "pallet-teebag", - "parity-scale-codec", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.3 (git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3)", - "ring 0.16.20", - "scale-info", - "secp256k1 0.28.0", - "serde 1.0.193", - "sgx_tstd", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "litentry-proc-macros" -version = "0.1.0" -source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#ea133d42f915d6e3cbbc51304f534d0b9f42e5d3" -dependencies = [ - "cargo_toml", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg 1.1.0", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "git+https://github.com/mesalock-linux/log-sgx?tag=sgx_1.1.3#2ca9039a9ebba0ed90ed2ad57425917d4b3a2a24" -dependencies = [ - "cfg-if 1.0.0", - "sgx_tstd", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "git+https://github.com/mesalock-linux/log-sgx#2ca9039a9ebba0ed90ed2ad57425917d4b3a2a24" -dependencies = [ - "cfg-if 1.0.0", - "sgx_tstd", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" - -[[package]] -name = "matrixmultiply" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" -dependencies = [ - "autocfg 1.1.0", - "rawpointer", -] - -[[package]] -name = "maybe-async" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1b8c13cb1f814b634a96b2c725449fe7ed464a7b8781de8688be5ffbd3f305" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "memchr" -version = "2.2.1" -source = "git+https://github.com/mesalock-linux/rust-memchr-sgx#fb51ee32766cb9a2be39b7fb2b5de26bb86dcdeb" -dependencies = [ - "sgx_libc", - "sgx_tstd", - "sgx_types", -] - -[[package]] -name = "memchr" -version = "2.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" - -[[package]] -name = "memfd" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" -dependencies = [ - "rustix 0.37.23", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "memory-db" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" -dependencies = [ - "hash-db 0.16.0", -] - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "merlin" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" -dependencies = [ - "byteorder 1.4.3", - "keccak", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.6.21" -source = "git+https://github.com/mesalock-linux/mio-sgx?tag=sgx_1.1.3#5b0e56a3066231c7a8d1876c7be3a19b08ffdfd5" -dependencies = [ - "iovec 0.1.4 (git+https://github.com/mesalock-linux/iovec-sgx)", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "net2 0.2.33", - "sgx_libc", - "sgx_trts", - "sgx_tstd", - "slab 0.4.2", -] - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys", - "libc", - "log 0.4.20", - "miow", - "net2 0.2.39", - "slab 0.4.8", - "winapi 0.2.8", -] - -[[package]] -name = "mio" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" -dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" -dependencies = [ - "lazycell", - "log 0.4.20", - "mio 0.6.23", - "slab 0.4.8", -] - -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "git+https://github.com/integritee-network/mio-extras-sgx?rev=963234b#963234bf55e44f9efff921938255126c48deef3a" -dependencies = [ - "lazycell", - "log 0.4.20", - "mio 0.6.21", - "mio 0.6.23", - "sgx_tstd", - "sgx_types", - "slab 0.4.8", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2 0.2.39", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "mockall" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" -dependencies = [ - "cfg-if 1.0.0", - "downcast", - "fragile", - "lazy_static", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" -dependencies = [ - "cfg-if 1.0.0", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "multer" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" -dependencies = [ - "bytes 1.4.0", - "encoding_rs", - "futures-util 0.3.28", - "http 0.2.9", - "httparse 1.8.0", - "log 0.4.20", - "memchr 2.6.3", - "mime", - "spin 0.9.8", - "version_check", -] - -[[package]] -name = "multihash" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab" -dependencies = [ - "generic-array 0.14.7", - "multihash-derive", - "unsigned-varint 0.5.1", -] - -[[package]] -name = "multihash-derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "musig2" -version = "0.0.8" -source = "git+https://github.com/kziemianek/musig2.git?branch=master#cd5e61ac9ecdf842da58605ac7b07b6e359f08c5" -dependencies = [ - "base16ct", - "hmac 0.12.1", - "k256", - "once_cell 1.19.0", - "secp 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.28.0", - "sha2 0.10.8", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "musig2" -version = "0.0.8" -source = "git+https://github.com/kailai-wang/musig2.git?branch=use-sha2-0.8#93857e52abbe8f9898c9ec743eecb1380132abcb" -dependencies = [ - "base16ct", - "hmac 0.12.1", - "k256", - "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx?branch=master)", - "secp 0.2.3 (git+https://github.com/kziemianek/secp.git?branch=sgx)", - "secp256k1 0.28.0", - "sgx_tstd", - "sha2 0.10.8", - "sha2_v08_wrapper", - "subtle 2.5.0 (git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update)", -] - -[[package]] -name = "nalgebra" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex 0.4.3", - "num-rational 0.4.1", - "num-traits 0.2.16", - "simba", - "typenum", -] - -[[package]] -name = "nalgebra-macros" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log 0.4.20", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "git+https://github.com/mesalock-linux/net2-rs-sgx#554583d15f3c9dff5d862a6ae64e227bb38fa729" -dependencies = [ - "cfg-if 0.1.10", - "sgx_libc", - "sgx_tstd", -] - -[[package]] -name = "net2" -version = "0.2.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "no-std-net" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" - -[[package]] -name = "nohash-hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr 2.6.3", - "minimal-lexical", -] - -[[package]] -name = "normalize-line-endings" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" - -[[package]] -name = "num" -version = "0.2.0" -source = "git+https://github.com/mesalock-linux/num-sgx#22645415542cc67551890dfdd34f4d5638b9ec78" -dependencies = [ - "num-bigint 0.2.5", - "num-complex 0.2.3", - "num-integer 0.1.41", - "num-iter 0.1.39", - "num-rational 0.2.2", - "num-traits 0.2.10", -] - -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-bigint 0.2.6", - "num-complex 0.2.4", - "num-integer 0.1.45", - "num-iter 0.1.43", - "num-rational 0.2.4", - "num-traits 0.2.16", -] - -[[package]] -name = "num" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" -dependencies = [ - "num-bigint 0.4.3", - "num-complex 0.4.3", - "num-integer 0.1.45", - "num-iter 0.1.43", - "num-rational 0.4.1", - "num-traits 0.2.16", -] - -[[package]] -name = "num-bigint" -version = "0.2.5" -source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" -dependencies = [ - "autocfg 1.1.0", - "num-integer 0.1.41", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.1.0", - "num-integer 0.1.45", - "num-traits 0.2.16", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg 1.1.0", - "num-integer 0.1.45", - "num-traits 0.2.16", -] - -[[package]] -name = "num-complex" -version = "0.2.3" -source = "git+https://github.com/mesalock-linux/num-complex-sgx#19700ad6de079ebc5560db472c282d1591e0d84f" -dependencies = [ - "autocfg 0.1.8", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg 1.1.0", - "num-traits 0.2.16", -] - -[[package]] -name = "num-complex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "num-format" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" -dependencies = [ - "arrayvec 0.7.4", - "itoa 1.0.9", -] - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" -dependencies = [ - "autocfg 0.1.8", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg 1.1.0", - "num-traits 0.2.16", -] - -[[package]] -name = "num-iter" -version = "0.1.39" -source = "git+https://github.com/mesalock-linux/num-iter-sgx#f19fc44fcad0b82a040e5a24c511e5049cc04b60" -dependencies = [ - "num-integer 0.1.41", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg 1.1.0", - "num-integer 0.1.45", - "num-traits 0.2.16", -] - -[[package]] -name = "num-rational" -version = "0.2.2" -source = "git+https://github.com/mesalock-linux/num-rational-sgx#be65f9ce439f3c9ec850d8041635ab6c3309b816" -dependencies = [ - "autocfg 0.1.8", - "num-bigint 0.2.5", - "num-integer 0.1.41", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.1.0", - "num-bigint 0.2.6", - "num-integer 0.1.45", - "num-traits 0.2.16", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg 1.1.0", - "num-bigint 0.4.3", - "num-integer 0.1.45", - "num-traits 0.2.16", -] - -[[package]] -name = "num-traits" -version = "0.2.10" -source = "git+https://github.com/mesalock-linux/num-traits-sgx#af046e0b15c594c960007418097dd4ff37ec3f7a" -dependencies = [ - "autocfg 0.1.8", - "sgx_tstd", -] - -[[package]] -name = "num-traits" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.2", - "libc", -] - -[[package]] -name = "object" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" -dependencies = [ - "crc32fast", - "hashbrown 0.12.3", - "indexmap 1.9.3", - "memchr 2.6.3", -] - -[[package]] -name = "object" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" -dependencies = [ - "memchr 2.6.3", -] - -[[package]] -name = "ofb" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e609fc8b72da3dabd56427be9489d8a9f4bd2e4dc41660dd033c3c8e90b93c" -dependencies = [ - "cipher", -] - -[[package]] -name = "once_cell" -version = "1.4.0" -source = "git+https://github.com/mesalock-linux/once_cell-sgx?branch=master#cefcaa03fed4d85276b3235d875f1b45d399cc3c" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "once_cell" -version = "1.4.0" -source = "git+https://github.com/mesalock-linux/once_cell-sgx#cefcaa03fed4d85276b3235d875f1b45d399cc3c" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell 1.19.0", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "ordered-multimap" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" -dependencies = [ - "dlv-list", - "hashbrown 0.12.3", -] - -[[package]] -name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" - -[[package]] -name = "pallet-assets" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-balances" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-evm" -version = "6.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" -dependencies = [ - "environmental 1.1.4", - "evm", - "fp-account", - "fp-evm", - "frame-benchmarking", - "frame-support", - "frame-system", - "hex", - "hex-literal", - "impl-trait-for-tuples", - "log 0.4.20", - "parity-scale-codec", - "rlp", - "scale-info", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-parentchain" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", -] - -[[package]] -name = "pallet-sudo" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-teebag" -version = "0.1.0" -source = "git+https://github.com/litentry/litentry-parachain?branch=release-v0.9.19#ea133d42f915d6e3cbbc51304f534d0b9f42e5d3" -dependencies = [ - "base64 0.13.1", - "chrono 0.4.26", - "der 0.6.1", - "frame-support", - "frame-system", - "hex", - "hex-literal", - "log 0.4.20", - "pallet-balances", - "pallet-timestamp", - "parity-scale-codec", - "ring 0.16.20", - "rustls-webpki", - "scale-info", - "serde 1.0.193", - "serde_json 1.0.103", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", - "x509-cert", -] - -[[package]] -name = "pallet-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "pallet-transaction-payment" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "parity-multiaddr" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58341485071825827b7f03cf7efd1cb21e6a709bea778fb50227fd45d2f361b4" -dependencies = [ - "arrayref", - "bs58", - "byteorder 1.4.3", - "data-encoding", - "multihash", - "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.193", - "static_assertions", - "unsigned-varint 0.7.1", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parity-scale-codec" -version = "3.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" -dependencies = [ - "arrayvec 0.7.4", - "bitvec", - "byte-slice-cast", - "bytes 1.4.0", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde 1.0.193", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "parity-util-mem" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" -dependencies = [ - "cfg-if 1.0.0", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "primitive-types", - "winapi 0.3.9", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec 1.11.0", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.3.5", - "smallvec 1.11.0", - "windows-targets 0.48.1", -] - -[[package]] -name = "parse_duration" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7037e5e93e0172a5a96874380bf73bc6ecef022e26fa25f2be26864d6b3ba95d" -dependencies = [ - "lazy_static", - "num 0.2.1", - "regex 1.9.5", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pathdiff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.0", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "pem" -version = "0.8.2" -source = "git+https://github.com/mesalock-linux/pem-rs-sgx#fdfef4f24a9fb3fa72e8a71bb28bd8ff15feff2f" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx)", - "regex 1.3.1", - "sgx_tstd", -] - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "git+https://github.com/mesalock-linux/rust-url-sgx?tag=sgx_1.1.3#23832f3191456c2d4a0faab10952e1747be58ca8" - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" - -[[package]] -name = "pest" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d2d1d55045829d65aad9d389139882ad623b33b904e7c9f1b10c5b8927298e5" -dependencies = [ - "thiserror 1.0.44", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f94bca7e7a599d89dea5dfa309e217e7906c3c007fb9c3299c40b10d6a315d3" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d490fe7e8556575ff6911e45567ab95e71617f43781e5c05490dc8d75c965c" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "pest_meta" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2674c66ebb4b4d9036012091b537aae5878970d6999f81a265034d85b136b341" -dependencies = [ - "once_cell 1.19.0", - "pest", - "sha2 0.10.8", -] - -[[package]] -name = "pin-project" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der 0.7.8", - "spki 0.7.2", -] - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "postcard" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25c0b0ae06fcffe600ad392aabfa535696c8973f2253d9ac83171924c58a858" -dependencies = [ - "postcard-cobs", - "serde 1.0.193", -] - -[[package]] -name = "postcard-cobs" -version = "0.1.5-pre" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "git+https://github.com/mesalock-linux/cryptocorrosion-sgx#32d7de50b5f03a10fe5a42167410be2dd3c2e389" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "predicates" -version = "2.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" -dependencies = [ - "difflib", - "float-cmp", - "itertools 0.10.5", - "normalize-line-endings", - "predicates-core", - "regex 1.9.5", -] - -[[package]] -name = "predicates-core" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" - -[[package]] -name = "predicates-tree" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" -dependencies = [ - "predicates-core", - "termtree", -] - -[[package]] -name = "primitive-types" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell 1.19.0", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - -[[package]] -name = "proc-macro-warning" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "proc-macro2" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "procfs" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de8dacb0873f77e6aefc6d71e044761fcc68060290f5b1089fcdf84626bb69" -dependencies = [ - "bitflags 1.3.2", - "byteorder 1.4.3", - "hex", - "lazy_static", - "rustix 0.36.15", -] - -[[package]] -name = "prometheus" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" -dependencies = [ - "cfg-if 1.0.0", - "fnv 1.0.7", - "lazy_static", - "libc", - "memchr 2.6.3", - "parking_lot 0.12.1", - "procfs", - "thiserror 1.0.44", -] - -[[package]] -name = "psm" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" -dependencies = [ - "cc", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3#83583f073de3b4f75c3c3ef5e174d484ed941f85" -dependencies = [ - "getrandom 0.1.14", - "rand_chacha 0.2.2 (git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3)", - "rand_core 0.5.1 (git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3)", - "sgx_tstd", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86 0.2.17", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3#83583f073de3b4f75c3c3ef5e174d484ed941f85" -dependencies = [ - "ppv-lite86 0.2.6", - "rand_core 0.5.1 (git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3)", - "sgx_tstd", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86 0.2.17", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3#83583f073de3b4f75c3c3ef5e174d484ed941f85" -dependencies = [ - "getrandom 0.1.14", - "sgx_tstd", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "rcgen" -version = "0.9.2" -source = "git+https://github.com/integritee-network/rcgen#1852c8dbeb74de36a422d218254b659497daf717" -dependencies = [ - "chrono 0.4.11", - "chrono 0.4.26", - "pem 0.8.2", - "pem 1.1.1", - "ring 0.16.19", - "ring 0.16.20", - "sgx_tstd", - "yasna 0.3.1", - "yasna 0.4.0", -] - -[[package]] -name = "rdrand" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5014f842b5515f60c15d3bca398477951f785883f73e7f9bc8a9d9c9bb6821c7" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", - "thiserror 1.0.44", -] - -[[package]] -name = "ref-cast" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ef7e18e8841942ddb1cf845054f8008410030a3997875d9e49b7a363063df1" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "regex" -version = "1.3.1" -source = "git+https://github.com/mesalock-linux/regex-sgx#76aef86f9836532d17764523d0fa23bb7d2e31cf" -dependencies = [ - "regex-syntax 0.6.12", - "sgx_tstd", -] - -[[package]] -name = "regex" -version = "1.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" -dependencies = [ - "aho-corasick", - "memchr 2.6.3", - "regex-automata 0.3.8", - "regex-syntax 0.7.5", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" -dependencies = [ - "aho-corasick", - "memchr 2.6.3", - "regex-syntax 0.7.5", -] - -[[package]] -name = "regex-syntax" -version = "0.6.12" -source = "git+https://github.com/mesalock-linux/regex-sgx#76aef86f9836532d17764523d0fa23bb7d2e31cf" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - -[[package]] -name = "reqwest" -version = "0.11.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" -dependencies = [ - "base64 0.21.2", - "bytes 1.4.0", - "encoding_rs", - "futures-core 0.3.28", - "futures-util 0.3.28", - "h2", - "http 0.2.9", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log 0.4.20", - "mime", - "native-tls", - "once_cell 1.19.0", - "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite", - "serde 1.0.193", - "serde_json 1.0.103", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tower-service", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac 0.12.1", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ring" -version = "0.16.19" -source = "git+https://github.com/mesalock-linux/ring-sgx?tag=v0.16.5#844efe271ed78a399d803b2579f5f2424d543c9f" -dependencies = [ - "cc", - "sgx_tstd", - "spin 0.5.2", - "untrusted 0.7.1", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "git+https://github.com/betrusted-io/ring-xous?branch=0.16.20-cleanup#4296c2e7904898766cf7d8d589759a129794783b" -dependencies = [ - "cc", - "libc", - "log 0.4.20", - "once_cell 1.19.0", - "rkyv", - "spin 0.5.2", - "untrusted 0.7.1", - "winapi 0.3.9", - "xous", - "xous-api-names", - "xous-ipc", -] - -[[package]] -name = "rkyv" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70de01b38fe7baba4ecdd33b777096d2b326993d8ea99bc5b6ede691883d3010" -dependencies = [ - "memoffset 0.6.5", - "ptr_meta", - "rkyv_derive", -] - -[[package]] -name = "rkyv_derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a169f6bc5a81033e86ed39d0f4150e2608160b73d2b93c6e8e6a3efa873f14" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes 1.4.0", - "rlp-derive", - "rustc-hex", -] - -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ron" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" -dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", - "serde 1.0.193", -] - -[[package]] -name = "rust-base58" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b313b91fcdc6719ad41fa2dad2b7e810b03833fae4bf911950e15529a5f04439" -dependencies = [ - "num 0.4.1", -] - -[[package]] -name = "rust-base58" -version = "0.0.4" -source = "git+https://github.com/mesalock-linux/rust-base58-sgx?rev=sgx_1.1.3#13fb3e0a543690e6e19332f37ba85fd74c56cb2f" -dependencies = [ - "num 0.2.0", - "sgx_tstd", -] - -[[package]] -name = "rust-ini" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" -dependencies = [ - "cfg-if 1.0.0", - "ordered-multimap", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.36.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" -dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys 0.4.3", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "ring 0.16.19", - "sct 0.6.0", - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "ring 0.16.19", - "sct 0.6.0", - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx)", - "ring 0.16.19", - "sct 0.6.0", - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log 0.4.20", - "ring 0.16.20", - "sct 0.6.1", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustls-native-certs" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" -dependencies = [ - "openssl-probe", - "rustls 0.19.1", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" -dependencies = [ - "base64 0.21.2", -] - -[[package]] -name = "rustls-pki-types" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47003264dea418db67060fa420ad16d0d2f8f0a0360d825c00e177ac52cb5d8" - -[[package]] -name = "rustls-webpki" -version = "0.102.0-alpha.3" -source = "git+https://github.com/rustls/webpki?rev=da923ed#da923edaab56f599971e58773617fb574cd019dc" -dependencies = [ - "ring 0.16.20", - "rustls-pki-types", - "untrusted 0.9.0", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "safe-lock" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "077d73db7973cccf63eb4aff1e5a34dc2459baa867512088269ea5f2f4253c90" - -[[package]] -name = "safe_arch" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "sc-keystore" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "array-bytes", - "async-trait", - "parking_lot 0.12.1", - "serde_json 1.0.103", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "thiserror 1.0.44", -] - -[[package]] -name = "scale-bits" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde 1.0.193", -] - -[[package]] -name = "scale-decode" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea509715113edab351e1f4d51fba6b186653259049a1155b52e2e994dd2f0e6d" -dependencies = [ - "parity-scale-codec", - "primitive-types", - "scale-bits", - "scale-decode-derive", - "scale-info", - "smallvec 1.11.0", -] - -[[package]] -name = "scale-decode-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c9d7a1341497e9d016722144310de3dc6c933909c0376017c88f65092fff37" -dependencies = [ - "darling", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "scale-encode" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6f51bc8cd927dab2f4567b1a8a8e9d7fd5d0866f2dbc7c84fc97cfa9383a26" -dependencies = [ - "parity-scale-codec", - "primitive-types", - "scale-bits", - "scale-encode-derive", - "scale-info", - "smallvec 1.11.0", -] - -[[package]] -name = "scale-encode-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28be1877787156a2df01be3c029b92bdffa6b6a9748d4996e383fff218c88f3" -dependencies = [ - "darling", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "scale-info" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" -dependencies = [ - "bitvec", - "cfg-if 1.0.0", - "derive_more", - "parity-scale-codec", - "scale-info-derive", - "serde 1.0.193", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "schnellru" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" -dependencies = [ - "ahash 0.8.3", - "cfg-if 1.0.0", - "hashbrown 0.13.2", -] - -[[package]] -name = "schnorrkel" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "curve25519-dalek 2.1.3", - "getrandom 0.1.16", - "merlin", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.2", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "sct" -version = "0.6.0" -source = "git+https://github.com/mesalock-linux/sct.rs?branch=mesalock_sgx#c4d859cca232e6c9d88ca12048df3bc26e1ed4ad" -dependencies = [ - "ring 0.16.19", - "sgx_tstd", - "untrusted 0.7.1", -] - -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der 0.7.8", - "generic-array 0.14.7", - "pkcs8", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize", -] - -[[package]] -name = "secp" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1507279bb0404bb566f85523e48fcf37a158daa5380577ee0d93f3ef4df39ccc" -dependencies = [ - "base16ct", - "k256", - "once_cell 1.19.0", - "secp256k1 0.28.0", - "subtle 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "secp" -version = "0.2.3" -source = "git+https://github.com/kziemianek/secp.git?branch=sgx#0479a3b12fc204015cdb63c138078fefe7e32341" -dependencies = [ - "base16ct", - "k256", - "once_cell 1.4.0 (git+https://github.com/mesalock-linux/once_cell-sgx?branch=master)", - "secp256k1 0.28.0", - "sgx_tstd", - "subtle 2.5.0 (git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update)", -] - -[[package]] -name = "secp256k1" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" -dependencies = [ - "secp256k1-sys 0.6.1", -] - -[[package]] -name = "secp256k1" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acea373acb8c21ecb5a23741452acd2593ed44ee3d343e72baaa143bc89d0d5" -dependencies = [ - "bitcoin_hashes", - "secp256k1-sys 0.9.1", -] - -[[package]] -name = "secp256k1" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" -dependencies = [ - "secp256k1-sys 0.10.0", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" -dependencies = [ - "cc", -] - -[[package]] -name = "secp256k1-sys" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd97a086ec737e30053fd5c46f097465d25bb81dd3608825f65298c4c98be83" -dependencies = [ - "cc", -] - -[[package]] -name = "secp256k1-sys" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" -dependencies = [ - "cc", -] - -[[package]] -name = "secrecy" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" -dependencies = [ - "zeroize", -] - -[[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" - -[[package]] -name = "serde" -version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" -dependencies = [ - "serde_derive 1.0.118", - "sgx_tstd", -] - -[[package]] -name = "serde" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" -dependencies = [ - "serde_derive 1.0.193", -] - -[[package]] -name = "serde-big-array" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b926cfbabfe8011609dda0350cb24d884955d294909ac71c0db7027366c77e3e" -dependencies = [ - "serde 1.0.193", - "serde_derive 1.0.193", -] - -[[package]] -name = "serde-big-array" -version = "0.3.0" -source = "git+https://github.com/mesalock-linux/serde-big-array-sgx#94122c5167aee38b39b09a620a60db2c28cf7428" -dependencies = [ - "serde 1.0.118", - "serde_derive 1.0.118", -] - -[[package]] -name = "serde_derive" -version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "serde_derive" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "serde_json" -version = "1.0.60" -source = "git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3#380893814ad2a057758d825bab798aa117f7362a" -dependencies = [ - "indexmap 1.6.1", - "itoa 0.4.5", - "ryu", - "serde 1.0.118", - "sgx_tstd", -] - -[[package]] -name = "serde_json" -version = "1.0.60" -source = "git+https://github.com/mesalock-linux/serde-json-sgx#380893814ad2a057758d825bab798aa117f7362a" -dependencies = [ - "itoa 0.4.5", - "ryu", - "serde 1.0.118", - "sgx_tstd", -] - -[[package]] -name = "serde_json" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" -dependencies = [ - "indexmap 2.0.0", - "itoa 1.0.9", - "ryu", - "serde 1.0.193", -] - -[[package]] -name = "serde_spanned" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 1.0.9", - "ryu", - "serde 1.0.193", -] - -[[package]] -name = "sgx_alloc" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" - -[[package]] -name = "sgx_backtrace_sys" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "cc", - "sgx_build_helper", - "sgx_libc", -] - -[[package]] -name = "sgx_build_helper" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" - -[[package]] -name = "sgx_crypto_helper" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "itertools 0.11.0", - "libc", - "serde 1.0.118", - "serde 1.0.193", - "serde-big-array 0.1.5", - "serde-big-array 0.3.0", - "serde_derive 1.0.118", - "serde_derive 1.0.193", - "sgx_tcrypto", - "sgx_tstd", - "sgx_types", - "sgx_ucrypto", -] - -[[package]] -name = "sgx_demangle" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" - -[[package]] -name = "sgx_libc" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_types", -] - -[[package]] -name = "sgx_rand" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_trts", - "sgx_tstd", - "sgx_types", -] - -[[package]] -name = "sgx_tcrypto" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_types", -] - -[[package]] -name = "sgx_tprotected_fs" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_trts", - "sgx_types", -] - -[[package]] -name = "sgx_trts" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_libc", - "sgx_types", -] - -[[package]] -name = "sgx_tse" -version = "1.1.6" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_types", -] - -[[package]] -name = "sgx_tstd" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "hashbrown_tstd", - "sgx_alloc", - "sgx_backtrace_sys", - "sgx_demangle", - "sgx_libc", - "sgx_tprotected_fs", - "sgx_trts", - "sgx_types", - "sgx_unwind", -] - -[[package]] -name = "sgx_types" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" - -[[package]] -name = "sgx_ucrypto" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "libc", - "rand_core 0.3.1", - "rdrand", - "sgx_types", -] - -[[package]] -name = "sgx_unwind" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_build_helper", -] - -[[package]] -name = "sgx_urts" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "libc", - "sgx_types", -] - -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "git+https://github.com/mesalock-linux/rust-sha1-sgx?tag=sgx_1.1.3#482a4d489e860d63a21662aaea988f600f8e20a4" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2_v08_wrapper" -version = "0.1.0" -source = "git+https://github.com/kailai-wang/sha2_v08#c41176becc675e84cd708e8b18ba2cd0c9cf8eb0" -dependencies = [ - "sha2 0.8.2", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" - -[[package]] -name = "signature" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "simba" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" -dependencies = [ - "approx", - "num-complex 0.4.3", - "num-traits 0.2.16", - "paste", - "wide", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "git+https://github.com/mesalock-linux/slab-sgx#0b0e6ec2abd588afd2f40fd082bc473d100d0f40" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "smallvec" -version = "1.6.1" -source = "git+https://github.com/mesalock-linux/rust-smallvec-sgx#b5925f10aa5bc3370a0fb339140ee063f5a888dd" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "soketto" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4919971d141dbadaa0e82b5d369e2d7666c98e4625046140615ca363e50d4daa" -dependencies = [ - "base64 0.13.1", - "bytes 1.4.0", - "futures 0.3.28", - "httparse 1.8.0", - "log 0.4.20", - "rand 0.8.5", - "sha-1 0.9.8", -] - -[[package]] -name = "sp-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "hash-db 0.16.0", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "sp-api-proc-macro", - "sp-core", - "sp-metadata-ir", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "sp-version", - "thiserror 1.0.44", -] - -[[package]] -name = "sp-api-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "Inflector", - "blake2", - "expander", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-std", -] - -[[package]] -name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "integer-sqrt", - "num-traits 0.2.16", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-std", - "static_assertions", -] - -[[package]] -name = "sp-consensus-grandpa" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "finality-grandpa", - "log 0.4.20", - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "array-bytes", - "bitflags 1.3.2", - "blake2", - "bounded-collections", - "bs58", - "dyn-clonable", - "ed25519-zebra", - "futures 0.3.28", - "hash-db 0.16.0", - "hash256-std-hasher", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log 0.4.20", - "merlin", - "parity-scale-codec", - "parking_lot 0.12.1", - "paste", - "primitive-types", - "rand 0.8.5", - "regex 1.9.5", - "scale-info", - "schnorrkel", - "secp256k1 0.24.3", - "secrecy", - "serde 1.0.193", - "sp-core-hashing", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "ss58-registry", - "substrate-bip39", - "thiserror 1.0.44", - "tiny-bip39", - "zeroize", -] - -[[package]] -name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "blake2b_simd", - "byteorder 1.4.3", - "digest 0.10.7", - "sha2 0.10.8", - "sha3", - "sp-std", - "twox-hash", -] - -[[package]] -name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "proc-macro2", - "quote", - "sp-core-hashing", - "syn 2.0.32", -] - -[[package]] -name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "environmental 1.1.4", - "parity-scale-codec", - "sp-std", - "sp-storage", -] - -[[package]] -name = "sp-inherents" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "async-trait", - "impl-trait-for-tuples", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", - "thiserror 1.0.44", -] - -[[package]] -name = "sp-io" -version = "7.0.0" -dependencies = [ - "itp-sgx-externalities", - "libsecp256k1", - "log 0.4.20", - "parity-scale-codec", - "sgx_tstd", - "sp-core", -] - -[[package]] -name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "bytes 1.4.0", - "ed25519", - "ed25519-dalek", - "futures 0.3.28", - "libsecp256k1", - "log 0.4.20", - "parity-scale-codec", - "rustversion", - "secp256k1 0.24.3", - "sp-core", - "sp-externalities", - "sp-keystore", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "tracing", - "tracing-core", -] - -[[package]] -name = "sp-keyring" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "lazy_static", - "sp-core", - "sp-runtime", - "strum 0.24.1", -] - -[[package]] -name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "futures 0.3.28", - "parity-scale-codec", - "parking_lot 0.12.1", - "serde 1.0.193", - "sp-core", - "sp-externalities", - "thiserror 1.0.44", -] - -[[package]] -name = "sp-metadata-ir" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-metadata", - "parity-scale-codec", - "scale-info", - "sp-std", -] - -[[package]] -name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "backtrace", - "lazy_static", - "regex 1.9.5", -] - -[[package]] -name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log 0.4.20", - "parity-scale-codec", - "paste", - "rand 0.8.5", - "scale-info", - "serde 1.0.193", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", - "sp-std", - "sp-weights", -] - -[[package]] -name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "bytes 1.4.0", - "impl-trait-for-tuples", - "parity-scale-codec", - "primitive-types", - "sp-externalities", - "sp-runtime-interface-proc-macro", - "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", - "static_assertions", -] - -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "sp-staking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "hash-db 0.16.0", - "log 0.4.20", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec 1.11.0", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-std", - "sp-trie", - "thiserror 1.0.44", - "tracing", -] - -[[package]] -name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" - -[[package]] -name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde 1.0.193", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "async-trait", - "futures-timer", - "log 0.4.20", - "parity-scale-codec", - "sp-inherents", - "sp-runtime", - "sp-std", - "thiserror 1.0.44", -] - -[[package]] -name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "parity-scale-codec", - "sp-std", - "tracing", - "tracing-core", - "tracing-subscriber", -] - -[[package]] -name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "ahash 0.8.3", - "hash-db 0.16.0", - "hashbrown 0.13.2", - "lazy_static", - "memory-db", - "nohash-hasher", - "parity-scale-codec", - "parking_lot 0.12.1", - "scale-info", - "schnellru", - "sp-core", - "sp-std", - "thiserror 1.0.44", - "tracing", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "parity-wasm", - "scale-info", - "serde 1.0.193", - "sp-core-hashing-proc-macro", - "sp-runtime", - "sp-std", - "sp-version-proc-macro", - "thiserror 1.0.44", -] - -[[package]] -name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "parity-scale-codec", - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "anyhow", - "impl-trait-for-tuples", - "log 0.4.20", - "parity-scale-codec", - "sp-std", - "wasmi", - "wasmtime", -] - -[[package]] -name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde 1.0.193", - "smallvec 1.11.0", - "sp-arithmetic", - "sp-core", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der 0.7.8", -] - -[[package]] -name = "ss58-registry" -version = "1.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" -dependencies = [ - "Inflector", - "num-format", - "proc-macro2", - "quote", - "serde 1.0.193", - "serde_json 1.0.103", - "unicode-xid", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros 0.24.3", -] - -[[package]] -name = "strum" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", -] - -[[package]] -name = "strum_macros" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.32", -] - -[[package]] -name = "substrate-api-client" -version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" -dependencies = [ - "ac-compose-macros", - "ac-node-api", - "ac-primitives", - "async-trait", - "derive_more", - "frame-metadata", - "frame-support", - "hex", - "log 0.4.20", - "maybe-async", - "parity-scale-codec", - "serde 1.0.193", - "serde_json 1.0.103", - "sp-core", - "sp-runtime", - "sp-runtime-interface", - "tungstenite 0.18.0", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "substrate-bip39" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" -dependencies = [ - "hmac 0.11.0", - "pbkdf2 0.8.0", - "schnorrkel", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "substrate-client-keystore" -version = "0.9.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" -dependencies = [ - "array-bytes", - "async-trait", - "parking_lot 0.12.1", - "sc-keystore", - "serde_json 1.0.103", - "sp-application-crypto", - "sp-core", - "sp-keyring", - "sp-keystore", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "subtle" -version = "2.5.0" -source = "git+https://github.com/kziemianek/subtle-sgx.git?branch=2.5.0-update#57c424bdb6b98cbf9cfe19879748f20c3525c80e" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "target-lexicon" -version = "0.12.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" - -[[package]] -name = "tempfile" -version = "3.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" -dependencies = [ - "cfg-if 1.0.0", - "fastrand", - "redox_syscall 0.3.5", - "rustix 0.38.4", - "windows-sys 0.48.0", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "termtree" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.9" -source = "git+https://github.com/mesalock-linux/thiserror-sgx?tag=sgx_1.1.3#c2f806b88616e06aab0af770366a76885d974fdc" -dependencies = [ - "sgx_tstd", - "thiserror-impl 1.0.9", -] - -[[package]] -name = "thiserror" -version = "1.0.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" -dependencies = [ - "thiserror-impl 1.0.44", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.9" -source = "git+https://github.com/mesalock-linux/thiserror-sgx?tag=sgx_1.1.3#c2f806b88616e06aab0af770366a76885d974fdc" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if 1.0.0", - "once_cell 1.19.0", -] - -[[package]] -name = "threadpool" -version = "1.8.0" -source = "git+https://github.com/mesalock-linux/rust-threadpool-sgx?tag=sgx_1.1.3#098d98a85b7e2b02e2bb451a3dec0b027017ff4c" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "tiny-bip39" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" -dependencies = [ - "anyhow", - "hmac 0.12.1", - "once_cell 1.19.0", - "pbkdf2 0.11.0", - "rand 0.8.5", - "rustc-hash", - "sha2 0.10.8", - "thiserror 1.0.44", - "unicode-normalization 0.1.22", - "wasm-bindgen", - "zeroize", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" -dependencies = [ - "autocfg 1.1.0", - "backtrace", - "bytes 1.4.0", - "libc", - "mio 0.8.8", - "num_cpus", - "parking_lot 0.12.1", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" -dependencies = [ - "rustls 0.19.1", - "tokio", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core 0.3.28", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" -dependencies = [ - "futures-util 0.3.28", - "log 0.4.20", - "tokio", - "tungstenite 0.18.0", -] - -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes 1.4.0", - "futures-core 0.3.28", - "futures-io 0.3.28", - "futures-sink 0.3.28", - "log 0.4.20", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" -dependencies = [ - "bytes 1.4.0", - "futures-core 0.3.28", - "futures-sink 0.3.28", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "toml" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" -dependencies = [ - "serde 1.0.193", - "serde_spanned", - "toml_datetime", - "toml_edit 0.20.2", -] - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" -dependencies = [ - "serde 1.0.193", -] - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.0.0", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap 2.0.0", - "serde 1.0.193", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if 1.0.0", - "log 0.4.20", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - -[[package]] -name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ - "once_cell 1.19.0", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log 0.4.20", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde 1.0.193", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" -dependencies = [ - "ansi_term", - "chrono 0.4.26", - "lazy_static", - "matchers", - "regex 1.9.5", - "serde 1.0.193", - "serde_json 1.0.103", - "sharded-slab", - "smallvec 1.11.0", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "trie-db" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" -dependencies = [ - "hash-db 0.16.0", - "hashbrown 0.13.2", - "log 0.4.20", - "rustc-hex", - "smallvec 1.11.0", -] - -[[package]] -name = "trie-root" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" -dependencies = [ - "hash-db 0.16.0", -] - -[[package]] -name = "triehash" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" -dependencies = [ - "hash-db 0.15.2", - "rlp", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "tt-call" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" - -[[package]] -name = "tungstenite" -version = "0.14.0" -source = "git+https://github.com/integritee-network/tungstenite-rs-sgx?branch=sgx-experimental#c87a2c08ea00897bb8b127ca0a5c30c3671492b0" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx?tag=sgx_1.1.3)", - "byteorder 1.3.4", - "bytes 1.0.1", - "http 0.2.1", - "httparse 1.4.1", - "log 0.4.14 (git+https://github.com/mesalock-linux/log-sgx?tag=sgx_1.1.3)", - "rand 0.7.3 (git+https://github.com/mesalock-linux/rand-sgx?tag=sgx_1.1.3)", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", - "sgx_tstd", - "sha1 0.6.0", - "thiserror 1.0.9", - "url 2.1.1", - "utf-8 0.7.4", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", - "webpki-roots 0.21.0 (git+https://github.com/mesalock-linux/webpki-roots?tag=sgx_1.1.3)", -] - -[[package]] -name = "tungstenite" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983d40747bce878d2fb67d910dcb8bd3eca2b2358540c3cc1b98c027407a3ae3" -dependencies = [ - "base64 0.13.1", - "byteorder 1.4.3", - "bytes 1.4.0", - "http 0.2.9", - "httparse 1.8.0", - "log 0.4.20", - "rand 0.8.5", - "rustls 0.19.1", - "sha-1 0.9.8", - "thiserror 1.0.44", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "utf-8 0.7.6", - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki-roots 0.21.1", -] - -[[package]] -name = "tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" -dependencies = [ - "base64 0.13.1", - "byteorder 1.4.3", - "bytes 1.4.0", - "http 0.2.9", - "httparse 1.8.0", - "log 0.4.20", - "native-tls", - "rand 0.8.5", - "sha1 0.10.5", - "thiserror 1.0.44", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "utf-8 0.7.6", -] - -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if 1.0.0", - "digest 0.10.7", - "rand 0.8.5", - "static_assertions", -] - -[[package]] -name = "typed-builder" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a46ee5bd706ff79131be9c94e7edcb82b703c487766a114434e5790361cf08c5" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder 1.4.3", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "git+https://github.com/mesalock-linux/unicase-sgx#0b0519348572927118af47af3da4da9ffdca8ec6" -dependencies = [ - "sgx_tstd", - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "git+https://github.com/mesalock-linux/unicode-bidi-sgx#eb10728a635a046e75747849fbc680cbbb7832c7" -dependencies = [ - "matches", - "sgx_tstd", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" - -[[package]] -name = "unicode-normalization" -version = "0.1.12" -source = "git+https://github.com/mesalock-linux/unicode-normalization-sgx#c1b030611969f87d75782c1df77975167cbbd509" -dependencies = [ - "smallvec 1.6.1", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "unsigned-varint" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" - -[[package]] -name = "unsigned-varint" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "url" -version = "2.1.1" -source = "git+https://github.com/mesalock-linux/rust-url-sgx?tag=sgx_1.1.3#23832f3191456c2d4a0faab10952e1747be58ca8" -dependencies = [ - "idna 0.2.0", - "matches", - "percent-encoding 2.1.0", - "sgx_tstd", -] - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "idna 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "url" -version = "2.5.0" -source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" -dependencies = [ - "form_urlencoded 1.2.1 (git+https://github.com/domenukk/rust-url?branch=no_std)", - "idna 0.5.0 (git+https://github.com/domenukk/rust-url?branch=no_std)", - "no-std-net", - "percent-encoding 2.3.1 (git+https://github.com/domenukk/rust-url?branch=no_std)", -] - -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - -[[package]] -name = "utf-8" -version = "0.7.4" -source = "git+https://github.com/integritee-network/rust-utf8-sgx?branch=sgx-experimental#b026700da83a2f00f0e9f36f813ef28e447a719e" -dependencies = [ - "sgx_tstd", -] - -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "walkdir" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "warp" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" -dependencies = [ - "bytes 1.4.0", - "futures-channel 0.3.28", - "futures-util 0.3.28", - "headers", - "http 0.2.9", - "hyper", - "log 0.4.20", - "mime", - "mime_guess", - "multer", - "percent-encoding 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project", - "rustls-pemfile", - "scoped-tls", - "serde 1.0.193", - "serde_json 1.0.103", - "serde_urlencoded", - "tokio", - "tokio-stream", - "tokio-tungstenite", - "tokio-util 0.7.8", - "tower-service", - "tracing", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log 0.4.20", - "once_cell 1.19.0", - "proc-macro2", - "quote", - "syn 2.0.32", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "wasmi" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" -dependencies = [ - "parity-wasm", - "wasmi-validation", - "wasmi_core", -] - -[[package]] -name = "wasmi-validation" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "wasmi_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" -dependencies = [ - "downcast-rs", - "libm", - "memory_units", - "num-rational 0.4.1", - "num-traits 0.2.16", -] - -[[package]] -name = "wasmparser" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" -dependencies = [ - "indexmap 1.9.3", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasmtime" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" -dependencies = [ - "anyhow", - "bincode", - "cfg-if 1.0.0", - "indexmap 1.9.3", - "libc", - "log 0.4.20", - "object 0.29.0", - "once_cell 1.19.0", - "paste", - "psm", - "serde 1.0.193", - "target-lexicon", - "wasmparser", - "wasmtime-environ", - "wasmtime-jit", - "wasmtime-runtime", - "windows-sys 0.42.0", -] - -[[package]] -name = "wasmtime-asm-macros" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "wasmtime-environ" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" -dependencies = [ - "anyhow", - "cranelift-entity", - "gimli 0.26.2", - "indexmap 1.9.3", - "log 0.4.20", - "object 0.29.0", - "serde 1.0.193", - "target-lexicon", - "thiserror 1.0.44", - "wasmparser", - "wasmtime-types", -] - -[[package]] -name = "wasmtime-jit" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" -dependencies = [ - "addr2line 0.17.0", - "anyhow", - "bincode", - "cfg-if 1.0.0", - "cpp_demangle", - "gimli 0.26.2", - "log 0.4.20", - "object 0.29.0", - "rustc-demangle", - "serde 1.0.193", - "target-lexicon", - "wasmtime-environ", - "wasmtime-jit-icache-coherence", - "wasmtime-runtime", - "windows-sys 0.42.0", -] - -[[package]] -name = "wasmtime-jit-debug" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" -dependencies = [ - "once_cell 1.19.0", -] - -[[package]] -name = "wasmtime-jit-icache-coherence" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "windows-sys 0.42.0", -] - -[[package]] -name = "wasmtime-runtime" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" -dependencies = [ - "anyhow", - "cc", - "cfg-if 1.0.0", - "indexmap 1.9.3", - "libc", - "log 0.4.20", - "mach", - "memfd", - "memoffset 0.6.5", - "paste", - "rand 0.8.5", - "rustix 0.36.15", - "wasmtime-asm-macros", - "wasmtime-environ", - "wasmtime-jit-debug", - "windows-sys 0.42.0", -] - -[[package]] -name = "wasmtime-types" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" -dependencies = [ - "cranelift-entity", - "serde 1.0.193", - "thiserror 1.0.44", - "wasmparser", -] - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "webpki" -version = "0.21.4" -source = "git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx#8dbe6fbeefadf05582ae47c7fa818b04db49c61e" -dependencies = [ - "ring 0.16.19", - "sgx_tstd", - "untrusted 0.7.1", -] - -[[package]] -name = "webpki-roots" -version = "0.21.0" -source = "git+https://github.com/mesalock-linux/webpki-roots?tag=sgx_1.1.3#6ff3be547ac13ccd46ae55605ad6506ce30688ef" -dependencies = [ - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "webpki-roots" -version = "0.21.0" -source = "git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx#6ff3be547ac13ccd46ae55605ad6506ce30688ef" -dependencies = [ - "sgx_tstd", - "webpki 0.21.4 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", -] - -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki 0.21.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wide" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" -dependencies = [ - "bytemuck", - "safe_arch", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-targets 0.48.1", -] - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.1", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "winnow" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b5872fa2e10bd067ae946f927e726d7d603eaeb6e02fa6a350e0722d2b8c11" -dependencies = [ - "memchr 2.6.3", -] - -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "ws" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25fe90c75f236a0a00247d5900226aea4f2d7b05ccc34da9e7a8880ff59b5848" -dependencies = [ - "byteorder 1.4.3", - "bytes 0.4.12", - "httparse 1.8.0", - "log 0.4.20", - "mio 0.6.23", - "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha-1 0.8.2", - "slab 0.4.8", - "url 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "x509-cert" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d224a125dec5adda27d0346b9cae9794830279c4f9c27e4ab0b6c408d54012" -dependencies = [ - "const-oid", - "der 0.6.1", - "flagset", - "spki 0.6.0", -] - -[[package]] -name = "xous" -version = "0.9.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a9f0a696320940ab2652fa1d20c98dc59eb7ba4591eeb91a3b8e40bc9255a1" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "xous-api-log" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e07c190c743d6d9e076f715333e94c48de41b99078343d174c707803df28c7" -dependencies = [ - "log 0.4.20", - "num-derive", - "num-traits 0.2.16", - "xous", - "xous-ipc", -] - -[[package]] -name = "xous-api-names" -version = "0.9.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d8361077e67966d25922056284d17d042cbb1c96a7ebc2584eb8181427cbb0" -dependencies = [ - "log 0.4.20", - "num-derive", - "num-traits 0.2.16", - "rkyv", - "xous", - "xous-api-log", - "xous-ipc", -] - -[[package]] -name = "xous-ipc" -version = "0.9.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee1d318dacbd6242e4e2291dee7c4532249e5a0845de05d264c20fc871a0a1a" -dependencies = [ - "bitflags 1.3.2", - "rkyv", - "xous", -] - -[[package]] -name = "yaml-rust" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map 0.5.6", -] - -[[package]] -name = "yasna" -version = "0.3.1" -source = "git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.3#a1f50714cd3eb29608ecf7888cacedc173edfdb2" -dependencies = [ - "bit-vec", - "chrono 0.4.11", - "num-bigint 0.2.5", - "sgx_tstd", -] - -[[package]] -name = "yasna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e262a29d0e61ccf2b6190d7050d4b237535fc76ce4c1210d9caa316f71dffa75" -dependencies = [ - "bit-vec", - "chrono 0.4.26", - "num-bigint 0.4.3", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] diff --git a/tee-worker/bitacross/Cargo.toml b/tee-worker/bitacross/Cargo.toml deleted file mode 100644 index 5b64c7fda0..0000000000 --- a/tee-worker/bitacross/Cargo.toml +++ /dev/null @@ -1,82 +0,0 @@ -[workspace] - -members = [ - "app-libs/parentchain-interface", - "app-libs/sgx-runtime", - "app-libs/stf", - "cli", - "core/direct-rpc-client", - "core/direct-rpc-server", - "core/offchain-worker-executor", - "core/parentchain/block-import-dispatcher", - "core/parentchain/block-importer", - "core/parentchain/indirect-calls-executor", - "core/parentchain/light-client", - "core/parentchain/parentchain-crate", - "core/rest-client", - "core/rpc-client", - "core/tls-websocket-server", - "core-primitives/attestation-handler", - "core-primitives/import-queue", - "core-primitives/component-container", - "core-primitives/enclave-api", - "core-primitives/enclave-api/ffi", - "core-primitives/enclave-metrics", - "core-primitives/extrinsics-factory", - "core-primitives/hashing", - "core-primitives/networking-utils", - "core-primitives/node-api", - "core-primitives/node-api/api-client-extensions", - "core-primitives/node-api/api-client-types", - "core-primitives/node-api/factory", - "core-primitives/node-api/metadata", - "core-primitives/node-api/metadata-provider", - "core-primitives/nonce-cache", - "core-primitives/ocall-api", - "core-primitives/primitives-cache", - "core-primitives/rpc", - "core-primitives/settings", - "core-primitives/sgx/crypto", - "core-primitives/sgx/io", - "core-primitives/sgx-runtime-primitives", - "core-primitives/stf-executor", - "core-primitives/stf-interface", - "core-primitives/stf-primitives", - "core-primitives/stf-state-handler", - "core-primitives/stf-state-observer", - "core-primitives/storage", - "core-primitives/substrate-sgx/environmental", - "core-primitives/substrate-sgx/externalities", - "core-primitives/substrate-sgx/sp-io", - "core-primitives/test", - "core-primitives/time-utils", - "core-primitives/top-pool", - "core-primitives/top-pool-author", - "core-primitives/types", - "core-primitives/utils", - "service", - "litentry/primitives", - "litentry/core/direct-call", - "bitacross/core/bc-task-processor", - "bitacross/core/bc-task-sender", - "bitacross/core/bc-enclave-registry", - "bitacross/core/bc-relayer-registry", - "bitacross/core/bc-signer-registry", - "bitacross/core/bc-musig2-ceremony", - "bitacross/core/bc-musig2-event", -] - -[patch."https://github.com/apache/teaclave-sgx-sdk.git"] -sgx_alloc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_crypto_helper = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_libc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_rand = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_tcrypto = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_trts = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_tstd = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_types = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_ucrypto = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_urts = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } - -[patch.crates-io] -ring = { git = "https://github.com/betrusted-io/ring-xous", branch = "0.16.20-cleanup" } diff --git a/tee-worker/bitacross/Makefile b/tee-worker/bitacross/Makefile index 21b7726e5c..5e84674de2 100755 --- a/tee-worker/bitacross/Makefile +++ b/tee-worker/bitacross/Makefile @@ -109,14 +109,14 @@ Worker_Rust_Flags := $(CARGO_TARGET) $(WORKER_FEATURES) Worker_Include_Paths := -I ./service -I./include -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) Worker_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(Worker_Include_Paths) -Worker_Rust_Path := target/$(OUTPUT_PATH) +Worker_Rust_Path := ../target/$(OUTPUT_PATH) Worker_Enclave_u_Object :=service/libEnclave_u.a Worker_Name := bin/app ######## bitacross-cli settings ######## Client_Rust_Flags := $(CARGO_TARGET) $(CLIENT_FEATURES) -Client_Rust_Path := target/$(OUTPUT_PATH) +Client_Rust_Path := ../target/$(OUTPUT_PATH) Client_Path := bin Client_Binary := bitacross-cli Client_Name := $(Client_Path)/$(Client_Binary) diff --git a/tee-worker/bitacross/README.md b/tee-worker/bitacross/README.md index e792bc5e06..e614d4be86 100755 --- a/tee-worker/bitacross/README.md +++ b/tee-worker/bitacross/README.md @@ -25,7 +25,7 @@ Rust code used in CLI module can also be used as a reference and can be found [h ```bash make SGX_MODE=SW -cd .. && local-setup/launch.py -w bitacross -wn 3 --parachain local-binary-standalone +cd ../.. && local-setup/launch.py -w bitacross -wn 3 -p standalone ``` ### Step by step guide for request preparing/sending and response handling. diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/Cargo.toml b/tee-worker/bitacross/app-libs/parentchain-interface/Cargo.toml index bad8c061fa..d4b0ccea49 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/Cargo.toml +++ b/tee-worker/bitacross/app-libs/parentchain-interface/Cargo.toml @@ -1,48 +1,42 @@ [package] -name = "ita-parentchain-interface" +name = "bc-ita-parentchain-interface" version = "0.1.0" authors = ["Integritee AG "] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, optional = true } -# local dependencies -ita-sgx-runtime = { path = "../sgx-runtime", default-features = false } -ita-stf = { path = "../stf", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../../core/parentchain/indirect-calls-executor", default-features = false } -itp-api-client-types = { path = "../../core-primitives/node-api/api-client-types", default-features = false } -itp-node-api = { path = "../../core-primitives/node-api", default-features = false } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } +ita-sgx-runtime = { package = "bc-ita-sgx-runtime", path = "../sgx-runtime", default-features = false } +ita-stf = { package = "bc-ita-stf", path = "../stf", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "bc-itc-parentchain-indirect-calls-executor", path = "../../core/parentchain/indirect-calls-executor", default-features = false } +itp-api-client-types = { workspace = true } +itp-node-api = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } -# no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } -substrate-api-client = { optional = true, default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# substrate dep -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +substrate-api-client = { workspace = true, optional = true } # litentry bc-enclave-registry = { path = "../../bitacross/core/bc-enclave-registry", default-features = false } bc-relayer-registry = { path = "../../bitacross/core/bc-relayer-registry", default-features = false } bc-signer-registry = { path = "../../bitacross/core/bc-signer-registry", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +litentry-primitives = { workspace = true } +sp-std = { workspace = true } [dev-dependencies] -env_logger = "0.9.0" -itp-node-api = { path = "../../core-primitives/node-api", features = ["mocks"] } -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-executor = { path = "../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../core-primitives/test" } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", features = ["mocks"] } -itc-parentchain-test = { path = "../../core/parentchain/test" } - +env_logger = { workspace = true } +itp-node-api = { workspace = true, features = ["std", "mocks"] } +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../core-primitives/stf-executor", features = ["std", "mocks"] } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../../core-primitives/top-pool-author", features = ["std", "mocks"] } +itc-parentchain-test = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_filter.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_filter.rs index 7007dbf511..2294044191 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_filter.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_filter.rs @@ -21,13 +21,7 @@ use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{ - events::{ - BalanceTransfer, BtcWalletGenerated, EnclaveAdded, EnclaveRemoved, EnclaveUnauthorized, - RelayerAdded, RelayerRemoved, - }, - FilterEvents, - }, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -68,7 +62,21 @@ impl From> for FilterableEvents { impl FilterEvents for FilterableEvents { type Error = itc_parentchain_indirect_calls_executor::Error; - fn get_transfer_events(&self) -> Result, Self::Error> { + fn get_link_identity_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_vc_requested_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_deactivate_identity_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + + fn get_activate_identity_events(&self) -> Result, Self::Error> { self.filter() } @@ -76,6 +84,20 @@ impl FilterEvents for FilterableEvents { self.filter() } + fn get_opaque_task_posted_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_assertion_created_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_parentchain_block_proccessed_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + fn get_relayer_added_events(&self) -> Result, Self::Error> { self.filter() } diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_handler.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_handler.rs index 1dd12a7748..94b3ba3efb 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_handler.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/integritee/event_handler.rs @@ -127,7 +127,13 @@ where EnclaveRegistry, >, { - fn handle_events(executor: &Executor, events: impl FilterEvents) -> Result, Error> { + type Output = Vec; + + fn handle_events( + &self, + executor: &Executor, + events: impl FilterEvents, + ) -> Result, Error> { let mut handled_events: Vec = Vec::new(); if let Ok(events) = events.get_relayer_added_events() { diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_filter.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_filter.rs index 01cfff5c73..56b5365130 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_filter.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_filter.rs @@ -20,13 +20,7 @@ use itc_parentchain_indirect_calls_executor::event_filter::ToEvents; use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{ - events::{ - BalanceTransfer, BtcWalletGenerated, EnclaveAdded, EnclaveRemoved, EnclaveUnauthorized, - RelayerAdded, RelayerRemoved, - }, - FilterEvents, - }, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -66,7 +60,21 @@ impl From> for FilterableEvents { impl FilterEvents for FilterableEvents { type Error = itc_parentchain_indirect_calls_executor::Error; - fn get_transfer_events(&self) -> Result, Self::Error> { + fn get_link_identity_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_vc_requested_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_deactivate_identity_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + + fn get_activate_identity_events(&self) -> Result, Self::Error> { self.filter() } @@ -74,6 +82,20 @@ impl FilterEvents for FilterableEvents { self.filter() } + fn get_opaque_task_posted_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_assertion_created_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_parentchain_block_proccessed_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + fn get_relayer_added_events(&self) -> Result, Self::Error> { self.filter() } diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_handler.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_handler.rs index 68728d210d..1a6a9188b3 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_handler.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_a/event_handler.rs @@ -50,7 +50,13 @@ where EnclaveRegistry, >, { - fn handle_events(_executor: &Executor, _events: impl FilterEvents) -> Result, Error> { + type Output = Vec; + + fn handle_events( + &self, + _executor: &Executor, + _events: impl FilterEvents, + ) -> Result, Error> { debug!("not handling any events for target a"); Ok(Vec::new()) } diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_filter.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_filter.rs index 01cfff5c73..56b5365130 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_filter.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_filter.rs @@ -20,13 +20,7 @@ use itc_parentchain_indirect_calls_executor::event_filter::ToEvents; use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{ - events::{ - BalanceTransfer, BtcWalletGenerated, EnclaveAdded, EnclaveRemoved, EnclaveUnauthorized, - RelayerAdded, RelayerRemoved, - }, - FilterEvents, - }, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -66,7 +60,21 @@ impl From> for FilterableEvents { impl FilterEvents for FilterableEvents { type Error = itc_parentchain_indirect_calls_executor::Error; - fn get_transfer_events(&self) -> Result, Self::Error> { + fn get_link_identity_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_vc_requested_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_deactivate_identity_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + + fn get_activate_identity_events(&self) -> Result, Self::Error> { self.filter() } @@ -74,6 +82,20 @@ impl FilterEvents for FilterableEvents { self.filter() } + fn get_opaque_task_posted_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_assertion_created_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_parentchain_block_proccessed_events( + &self, + ) -> Result, Self::Error> { + self.filter() + } + fn get_relayer_added_events(&self) -> Result, Self::Error> { self.filter() } diff --git a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_handler.rs b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_handler.rs index 6c76d3d02d..a822fc6919 100644 --- a/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_handler.rs +++ b/tee-worker/bitacross/app-libs/parentchain-interface/src/target_b/event_handler.rs @@ -50,7 +50,13 @@ where EnclaveRegistry, >, { - fn handle_events(_executor: &Executor, _events: impl FilterEvents) -> Result, Error> { + type Output = Vec; + + fn handle_events( + &self, + _executor: &Executor, + _events: impl FilterEvents, + ) -> Result, Error> { debug!("not handling any events for target B"); Ok(Vec::new()) } diff --git a/tee-worker/bitacross/app-libs/sgx-runtime/Cargo.toml b/tee-worker/bitacross/app-libs/sgx-runtime/Cargo.toml index 444efe9a53..4c543ff2f1 100644 --- a/tee-worker/bitacross/app-libs/sgx-runtime/Cargo.toml +++ b/tee-worker/bitacross/app-libs/sgx-runtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ita-sgx-runtime" +name = "bc-ita-sgx-runtime" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" @@ -8,27 +8,25 @@ edition = "2021" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", workspace = true } +scale-info = { workspace = true } -# local dependencies -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } - -# Substrate dependencies -frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +itp-sgx-runtime-primitives = { workspace = true } +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +pallet-balances = { workspace = true } +pallet-sudo = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-transaction-payment = { workspace = true } +sp-api = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +sp-version = { workspace = true } +# TODO - move to tee-worker pallets pallet-parentchain = { path = "../../../../parachain/worker-pallets/parentchain", default-features = false } [features] diff --git a/tee-worker/bitacross/app-libs/stf/Cargo.toml b/tee-worker/bitacross/app-libs/stf/Cargo.toml index df7df883aa..1111f64f0c 100644 --- a/tee-worker/bitacross/app-libs/stf/Cargo.toml +++ b/tee-worker/bitacross/app-libs/stf/Cargo.toml @@ -1,47 +1,43 @@ [package] -name = "ita-stf" +name = "bc-ita-stf" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# crates.io -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -hex = { version = "0.4", default-features = false } -hex-literal = { version = "0.4" } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +hex-literal = { workspace = true } +log = { workspace = true } -# sgx deps -sgx_tstd = { branch = "master", features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, features = ["untrusted_fs", "net", "backtrace"], optional = true } -# local crates -ita-sgx-runtime = { default-features = false, path = "../sgx-runtime" } -itp-hashing = { default-features = false, path = "../../core-primitives/hashing" } -itp-node-api = { default-features = false, path = "../../core-primitives/node-api" } -itp-sgx-externalities = { default-features = false, path = "../../core-primitives/substrate-sgx/externalities" } -itp-stf-interface = { default-features = false, path = "../../core-primitives/stf-interface" } -itp-stf-primitives = { default-features = false, path = "../../core-primitives/stf-primitives" } -itp-storage = { default-features = false, path = "../../core-primitives/storage" } -itp-types = { default-features = false, path = "../../core-primitives/types" } -itp-utils = { default-features = false, path = "../../core-primitives/utils" } -sp-io = { default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"], path = "../../core-primitives/substrate-sgx/sp-io" } +itp-hashing = { workspace = true } +itp-node-api = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } -# Substrate dependencies -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +ita-sgx-runtime = { package = "bc-ita-sgx-runtime", path = "../sgx-runtime", default-features = false } +sp-io = { path = "../../../common/core-primitives/substrate-sgx/sp-io", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"] } + +frame-support = { workspace = true } +frame-system = { workspace = true } +pallet-balances = { workspace = true } +pallet-sudo = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } -# litentry litentry-macros = { path = "../../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +litentry-primitives = { workspace = true } pallet-parentchain = { path = "../../../../parachain/worker-pallets/parentchain", default-features = false } [dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-keyring = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/app-libs/stf/src/trusted_call.rs b/tee-worker/bitacross/app-libs/stf/src/trusted_call.rs index f4e37a8aec..8d8167d46b 100644 --- a/tee-worker/bitacross/app-libs/stf/src/trusted_call.rs +++ b/tee-worker/bitacross/app-libs/stf/src/trusted_call.rs @@ -150,6 +150,10 @@ impl TrustedCallVerification for TrustedCallSigned { self.signature.verify(&blake2_256(&payload), self.call.sender_identity()) || self.signature.verify(&payload, self.call.sender_identity()) } + + fn metric_name(&self) -> &'static str { + "unsupported_trusted_call" + } } impl ExecuteCall for TrustedCallSigned diff --git a/tee-worker/bitacross/bitacross/core/bc-enclave-registry/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-enclave-registry/Cargo.toml index 17f615bf4f..f9fdf7f312 100644 --- a/tee-worker/bitacross/bitacross/core/bc-enclave-registry/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-enclave-registry/Cargo.toml @@ -4,34 +4,29 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -thiserror = { version = "1.0.26", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-std = { workspace = true } + +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# internal dependencies -itp-settings = { path = "../../../core-primitives/settings", default-features = false } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -# litentry primities -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +itp-settings = { workspace = true } +itp-sgx-io = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -base64 = { version = "0.13", features = ["alloc"] } +base64 = { workspace = true, features = ["alloc"] } [features] default = ["std"] -production = [ -] +production = [] sgx = [ "sgx_tstd", - "thiserror-sgx", + "thiserror_sgx", "itp-sgx-io/sgx", "litentry-primitives/sgx", ] diff --git a/tee-worker/bitacross/bitacross/core/bc-musig2-ceremony/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-musig2-ceremony/Cargo.toml index fb1c5b6d46..352e059c92 100644 --- a/tee-worker/bitacross/bitacross/core/bc-musig2-ceremony/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-musig2-ceremony/Cargo.toml @@ -4,26 +4,21 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -musig2 = { package = "musig2", branch = "master", git = "https://github.com/kziemianek/musig2.git", optional = true, features = ["k256"] } +musig2 = { workspace = true, optional = true } rand = { version = "0.8.5", optional = true } # sgx dependencies -musig2_sgx = { package = "musig2", git = "https://github.com/kailai-wang/musig2.git", branch = "use-sha2-0.8", optional = true, features = ["k256"] } -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } +musig2_sgx = { workspace = true, optional = true } +sgx_rand = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -k256 = { version = "0.13.3", default-features = false, features = ["ecdsa-core", "schnorr", "alloc"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +k256 = { workspace = true, features = ["ecdsa-core", "schnorr", "alloc"] } +log = { workspace = true } -# local -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +itp-sgx-crypto = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] rand = { version = "0.8.5" } diff --git a/tee-worker/bitacross/bitacross/core/bc-musig2-event/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-musig2-event/Cargo.toml index 60ce17a4cd..3d90c0819c 100644 --- a/tee-worker/bitacross/bitacross/core/bc-musig2-event/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-musig2-event/Cargo.toml @@ -4,38 +4,35 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -threadpool = { version = "1.8.0", optional = true } +threadpool = { workspace = true, optional = true } # sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } -threadpool_sgx = { git = "https://github.com/mesalock-linux/rust-threadpool-sgx", package = "threadpool", tag = "sgx_1.1.3", optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +threadpool_sgx = { workspace = true, optional = true } bc-enclave-registry = { path = "../bc-enclave-registry", default-features = false } bc-musig2-ceremony = { path = "../bc-musig2-ceremony", default-features = false } -itc-direct-rpc-client = { path = "../../../core/direct-rpc-client", default-features = false } -itc-direct-rpc-server = { path = "../../../core/direct-rpc-server", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-rpc = { path = "../../../core-primitives/rpc", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } -itp-utils = { path = "../../../core-primitives/utils", default-features = false } lc-direct-call = { path = "../../../litentry/core/direct-call", default-features = false } -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } + +itc-direct-rpc-client = { package = "bc-itc-direct-rpc-client", path = "../../../core/direct-rpc-client", default-features = false } +itc-direct-rpc-server = { package = "bc-itc-direct-rpc-server", path = "../../../core/direct-rpc-server", default-features = false } +itp-ocall-api = { workspace = true } +itp-rpc = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } +litentry-primitives = { workspace = true } rand = { version = "0.8.5", optional = true } -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sgx_rand = { workspace = true, optional = true } +sp-core = { workspace = true, features = ["full_crypto"] } -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } [dev-dependencies] rand = { version = "0.8.5" } - [features] default = ["std"] std = [ diff --git a/tee-worker/bitacross/bitacross/core/bc-relayer-registry/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-relayer-registry/Cargo.toml index 3cb7f94081..6ce57e3e91 100644 --- a/tee-worker/bitacross/bitacross/core/bc-relayer-registry/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-relayer-registry/Cargo.toml @@ -4,33 +4,28 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -thiserror = { version = "1.0.26", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-std = { workspace = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# internal dependencies -itp-settings = { path = "../../../core-primitives/settings", default-features = false } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -# litentry primities -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +itp-settings = { workspace = true } +itp-sgx-io = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -base64 = { version = "0.13", features = ["alloc"] } +base64 = { workspace = true, features = ["alloc"] } [features] default = ["std"] development = [] sgx = [ "sgx_tstd", - "thiserror-sgx", + "thiserror_sgx", "itp-sgx-io/sgx", "litentry-primitives/sgx", ] diff --git a/tee-worker/bitacross/bitacross/core/bc-signer-registry/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-signer-registry/Cargo.toml index ea24abc9c1..7aaf9887d2 100644 --- a/tee-worker/bitacross/bitacross/core/bc-signer-registry/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-signer-registry/Cargo.toml @@ -4,26 +4,21 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -thiserror = { version = "1.0.26", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-std = { workspace = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# internal dependencies -itp-settings = { path = "../../../core-primitives/settings", default-features = false } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -# litentry primities -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +itp-settings = { workspace = true } +itp-sgx-io = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -base64 = { version = "0.13", features = ["alloc"] } +base64 = { workspace = true, features = ["alloc"] } [features] default = ["std"] @@ -31,7 +26,7 @@ production = [ ] sgx = [ "sgx_tstd", - "thiserror-sgx", + "thiserror_sgx", "itp-sgx-io/sgx", "litentry-primitives/sgx", ] diff --git a/tee-worker/bitacross/bitacross/core/bc-task-processor/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-task-processor/Cargo.toml index 080c11a119..f315dc434a 100644 --- a/tee-worker/bitacross/bitacross/core/bc-task-processor/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-task-processor/Cargo.toml @@ -4,48 +4,40 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -thiserror = { version = "1.0.26", optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } -threadpool = { version = "1.8.0", optional = true } - -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } -threadpool_sgx = { git = "https://github.com/mesalock-linux/rust-threadpool-sgx", package = "threadpool", tag = "sgx_1.1.3", optional = true } +futures_sgx = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } +threadpool = { workspace = true, optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +threadpool_sgx = { workspace = true, optional = true } -# internal dependencies -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +frame-support = { workspace = true } +log = { workspace = true } -ita-stf = { path = "../../../app-libs/stf", default-features = false } -itp-enclave-metrics = { path = "../../../core-primitives/enclave-metrics", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-externalities = { path = "../../../core-primitives/substrate-sgx/externalities", default-features = false } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", default-features = false } -itp-stf-state-handler = { path = "../../../core-primitives/stf-state-handler", default-features = false } +ita-stf = { package = "bc-ita-stf", path = "../../../app-libs/stf", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } +itp-stf-state-handler = { workspace = true } -# litentry primities bc-enclave-registry = { path = "../bc-enclave-registry", default-features = false } bc-musig2-ceremony = { path = "../bc-musig2-ceremony", default-features = false } bc-musig2-event = { path = "../bc-musig2-event", default-features = false } bc-relayer-registry = { path = "../bc-relayer-registry", default-features = false } bc-signer-registry = { path = "../bc-signer-registry", default-features = false } -itc-direct-rpc-client = { path = "../../../core/direct-rpc-client", default-features = false } -itc-direct-rpc-server = { path = "../../../core/direct-rpc-server", default-features = false } +bc-task-sender = { path = "../bc-task-sender", default-features = false } +itc-direct-rpc-client = { package = "bc-itc-direct-rpc-client", path = "../../../core/direct-rpc-client", default-features = false } +itc-direct-rpc-server = { package = "bc-itc-direct-rpc-server", path = "../../../core/direct-rpc-server", default-features = false } lc-direct-call = { path = "../../../litentry/core/direct-call", default-features = false } -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +litentry-primitives = { workspace = true } -bc-task-sender = { path = "../bc-task-sender", default-features = false } +sgx_crypto_helper = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } [features] default = ["std"] @@ -93,5 +85,6 @@ std = [ "thiserror", "itc-direct-rpc-server/std", "itc-direct-rpc-client/std", + "sgx_crypto_helper/default", ] development = [] diff --git a/tee-worker/bitacross/bitacross/core/bc-task-sender/Cargo.toml b/tee-worker/bitacross/bitacross/core/bc-task-sender/Cargo.toml index 20a7873bc5..6d0233f459 100644 --- a/tee-worker/bitacross/bitacross/core/bc-task-sender/Cargo.toml +++ b/tee-worker/bitacross/bitacross/core/bc-task-sender/Cargo.toml @@ -4,22 +4,16 @@ authors = ["Trust Computing GmbH "] version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -futures = { version = "0.3.8", optional = true } +futures = { workspace = true, optional = true } -# sgx dependencies -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["net", "thread"], optional = true } +futures_sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } +codec = { package = "parity-scale-codec", workspace = true } +lazy_static = { workspace = true } -# litentry primities -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/cli/Cargo.toml b/tee-worker/bitacross/cli/Cargo.toml index e5ea70ff4a..86bcdb8911 100644 --- a/tee-worker/bitacross/cli/Cargo.toml +++ b/tee-worker/bitacross/cli/Cargo.toml @@ -5,50 +5,46 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates-io no_std deps -arrayvec = { version = "0.7.1", default-features = false } -bit-vec = { version = "0.6", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -itertools = { default-features = false, version = "0.10.1" } -log = { version = "0.4", default-features = false } - -# std only deps -base64 = { version = "0.13", features = ["alloc"], optional = true } -chrono = { version = "0.4.19", features = ["alloc"], optional = true } -rustls = { version = "0.19", optional = true } -serde_json = { version = "1.0", features = ["preserve_order"], optional = true } -thiserror = { version = "1.0", optional = true } -webpki = { version = "0.21", optional = true } - -# mesalock -base64_sgx = { package = "base64", rev = "sgx_1.1.3", git = "https://github.com/mesalock-linux/rust-base64-sgx", optional = true } -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -num-bigint = { optional = true, git = "https://github.com/mesalock-linux/num-bigint-sgx" } -rustls_sgx = { package = "rustls", rev = "sgx_1.1.3", features = ["dangerous_configuration"], git = "https://github.com/mesalock-linux/rustls", optional = true } -serde_json_sgx = { package = "serde_json", tag = "sgx_1.1.3", features = ["preserve_order"], git = "https://github.com/mesalock-linux/serde-json-sgx", optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } -webpki-roots = { git = "https://github.com/mesalock-linux/webpki-roots", branch = "mesalock_sgx" } -webpki_sgx = { package = "webpki", git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx", optional = true } -yasna_sgx = { package = "yasna", optional = true, default-features = false, features = ["bit-vec", "num-bigint", "chrono", "mesalock_sgx"], git = "https://github.com/mesalock-linux/yasna.rs-sgx", rev = "sgx_1.1.3" } - -# sgx -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tcrypto = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tse = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["untrusted_fs", "net", "backtrace"], optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["extra_traits"] } - -# local deps -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-settings = { path = "../settings" } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-io = { path = "../sgx/io", default-features = false } -itp-time-utils = { path = "../time-utils", default-features = false } - -# integritee -httparse = { default-features = false, git = "https://github.com/integritee-network/httparse-sgx", branch = "sgx-experimental" } - -# substrate deps -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - # crates-io no_std - "arrayvec/std", - "codec/std", - "hex/std", - "log/std", - "itertools/use_std", - # optional std only - "base64", - "chrono", - "rustls", - "serde_json", - "thiserror", - "webpki", - # local - "itp-ocall-api/std", - "itp-sgx-io/std", - "itp-sgx-crypto/std", - # substrate - "sp-core/std", - # integritee - "httparse/std", -] - -sgx = [ - # sgx-only - "base64_sgx", - "chrono_sgx", - "rustls_sgx", - "serde_json_sgx", - "thiserror_sgx", - "webpki_sgx", - "yasna_sgx", - "sgx_tse", - "sgx_tstd", - "sgx_rand", - "sgx_tcrypto", - "num-bigint", - # local - "itp-sgx-io/sgx", - "itp-sgx-crypto/sgx", - # integritee - "httparse/mesalock_sgx", -] -test = [] -development = [] diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/src/attestation_handler.rs b/tee-worker/bitacross/core-primitives/attestation-handler/src/attestation_handler.rs deleted file mode 100644 index 07956058ad..0000000000 --- a/tee-worker/bitacross/core-primitives/attestation-handler/src/attestation_handler.rs +++ /dev/null @@ -1,853 +0,0 @@ -// Copyright 2022 Integritee AG and Supercomputing Systems AG -// Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Baidu, Inc., nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{cert, Error as EnclaveError, Error, Result as EnclaveResult}; -use codec::Encode; -use core::{convert::TryInto, default::Default}; -use itertools::Itertools; -use itp_ocall_api::EnclaveAttestationOCallApi; -use itp_settings::{ - files::{RA_API_KEY_FILE, RA_DUMP_CERT_DER_FILE, RA_SPID_FILE}, - worker::MR_ENCLAVE_SIZE, -}; -use itp_sgx_crypto::key_repository::AccessKey; -use itp_sgx_io as io; -use itp_time_utils::now_as_secs; -use log::*; -use sgx_rand::{os, Rng}; -use sgx_tcrypto::{rsgx_sha256_slice, SgxEccHandle}; -use sgx_tse::{rsgx_create_report, rsgx_verify_report}; -use sgx_types::{ - c_int, sgx_epid_group_id_t, sgx_quote_nonce_t, sgx_quote_sign_type_t, sgx_report_data_t, - sgx_spid_t, sgx_status_t, sgx_target_info_t, SgxResult, *, -}; -use sp_core::{ed25519, Pair}; -use std::{ - borrow::ToOwned, - env, format, - io::{Read, Write}, - net::TcpStream, - prelude::v1::*, - println, str, - string::{String, ToString}, - sync::Arc, - vec::Vec, -}; - -pub const DEV_HOSTNAME: &str = "api.trustedservices.intel.com"; - -// Litentry TODO: use `dev` for production temporary. Will switch to dcap later. -#[cfg(not(feature = "development"))] -pub const SIGRL_SUFFIX: &str = "/sgx/dev/attestation/v4/sigrl/"; -#[cfg(not(feature = "development"))] -pub const REPORT_SUFFIX: &str = "/sgx/dev/attestation/v4/report"; - -#[cfg(feature = "development")] -pub const SIGRL_SUFFIX: &str = "/sgx/dev/attestation/v4/sigrl/"; -#[cfg(feature = "development")] -pub const REPORT_SUFFIX: &str = "/sgx/dev/attestation/v4/report"; - -/// Trait to provide an abstraction to the attestation logic -pub trait AttestationHandler { - /// Generates an encoded remote attestation certificate. Returns DER encoded certificate. - /// If skip_ra is set, it will not perform a remote attestation via IAS - /// but instead generate a mock certificate. - fn generate_ias_ra_cert(&self, skip_ra: bool) -> EnclaveResult>; - - /// Returns the DER encoded private_key, DER encoded certificate and the raw DCAP quote. - /// If skip_ra is set, it will not perform a remote attestation via IAS - /// but instead generate a mock certificate. - fn generate_dcap_ra_cert( - &self, - quoting_enclave_target_info: Option<&sgx_target_info_t>, - quote_size: Option<&u32>, - skip_ra: bool, - ) -> EnclaveResult<(Vec, Vec, Vec)>; - - /// Get the measurement register value of the enclave - fn get_mrenclave(&self) -> EnclaveResult<[u8; MR_ENCLAVE_SIZE]>; - - /// Write the remote attestation report to the disk - fn dump_ias_ra_cert_to_disk(&self) -> EnclaveResult<()>; - - /// Write the remote attestation report to the disk - fn dump_dcap_ra_cert_to_disk( - &self, - quoting_enclave_target_info: &sgx_target_info_t, - quote_size: u32, - ) -> EnclaveResult<()>; - - /// Create the remote attestation report and encapsulate it in a DER certificate - /// Returns a pair consisting of (private key DER, certificate DER) - fn create_epid_ra_report_and_signature( - &self, - sign_type: sgx_quote_sign_type_t, - skip_ra: bool, - ) -> EnclaveResult<(Vec, Vec)>; -} - -pub struct IntelAttestationHandler { - pub(crate) ocall_api: Arc, - pub(crate) signing_key_repo: Arc, -} - -impl IntelAttestationHandler -where - OCallApi: EnclaveAttestationOCallApi, - AccessSigningKey: AccessKey, -{ - fn create_payload_epid( - &self, - pub_k: &[u8; 32], - sign_type: sgx_quote_sign_type_t, - ) -> EnclaveResult { - info!(" [Enclave] Create attestation report"); - let (attn_report, sig, cert) = match self.create_epid_attestation_report(&pub_k, sign_type) - { - Ok(r) => r, - Err(e) => { - error!(" [Enclave] Error in create_attestation_report: {:?}", e); - return Err(e.into()) - }, - }; - println!(" [Enclave] Create attestation report successful"); - debug!(" attn_report = {:?}", attn_report); - debug!(" sig = {:?}", sig); - debug!(" cert = {:?}", cert); - - // concat the information - Ok(attn_report + "|" + &sig + "|" + &cert) - } -} - -impl AttestationHandler - for IntelAttestationHandler -where - OCallApi: EnclaveAttestationOCallApi, - AccessSigningKey: AccessKey, -{ - fn generate_ias_ra_cert(&self, skip_ra: bool) -> EnclaveResult> { - // Our certificate is unlinkable. - let sign_type = sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE; - - // FIXME: should call `create_ra_report_and_signature` in skip_ra mode as well: - // https://github.com/integritee-network/worker/issues/321. - let cert_der = if !skip_ra { - match self.create_epid_ra_report_and_signature(sign_type, skip_ra) { - Ok((_key_der, cert_der)) => cert_der, - Err(e) => return Err(e), - } - } else { - self.get_mrenclave()?.encode() - }; - - Ok(cert_der) - } - - fn get_mrenclave(&self) -> EnclaveResult<[u8; MR_ENCLAVE_SIZE]> { - match self.ocall_api.get_mrenclave_of_self() { - Ok(m) => Ok(m.m), - Err(e) => Err(EnclaveError::Sgx(e)), - } - } - - fn dump_ias_ra_cert_to_disk(&self) -> EnclaveResult<()> { - // our certificate is unlinkable - let sign_type = sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE; - - let (_key_der, cert_der) = match self.create_epid_ra_report_and_signature(sign_type, false) - { - Ok(r) => r, - Err(e) => return Err(e), - }; - - if let Err(err) = io::write(&cert_der, RA_DUMP_CERT_DER_FILE) { - error!( - " [Enclave] failed to write RA file ({}), status: {:?}", - RA_DUMP_CERT_DER_FILE, err - ); - return Err(Error::IoError(err)) - } - info!(" [Enclave] dumped ra cert to {}", RA_DUMP_CERT_DER_FILE); - Ok(()) - } - - fn dump_dcap_ra_cert_to_disk( - &self, - quoting_enclave_target_info: &sgx_target_info_t, - quote_size: u32, - ) -> EnclaveResult<()> { - let (_priv_key_der, _cert_der, dcap_quote) = match self.generate_dcap_ra_cert( - Some(quoting_enclave_target_info), - Some("e_size), - false, - ) { - Ok(r) => r, - Err(e) => return Err(e), - }; - - if let Err(err) = io::write(&dcap_quote, RA_DUMP_CERT_DER_FILE) { - error!( - " [Enclave] failed to write RA file ({}), status: {:?}", - RA_DUMP_CERT_DER_FILE, err - ); - return Err(Error::IoError(err)) - } - info!(" [Enclave] dumped ra cert to {}", RA_DUMP_CERT_DER_FILE); - Ok(()) - } - - fn create_epid_ra_report_and_signature( - &self, - sign_type: sgx_quote_sign_type_t, - skip_ra: bool, - ) -> EnclaveResult<(Vec, Vec)> { - let chain_signer = self.signing_key_repo.retrieve_key()?; - info!("[Enclave Attestation] Ed25519 pub raw : {:?}", chain_signer.public().0); - - info!(" [Enclave] Generate keypair"); - let ecc_handle = SgxEccHandle::new(); - let _result = ecc_handle.open(); - let (prv_k, pub_k) = ecc_handle.create_key_pair()?; - info!(" [Enclave] Generate ephemeral ECDSA keypair successful"); - debug!(" pubkey X is {:02x}", pub_k.gx.iter().format("")); - debug!(" pubkey Y is {:02x}", pub_k.gy.iter().format("")); - - let payload = if !skip_ra { - self.create_payload_epid(&chain_signer.public().0, sign_type)? - } else { - Default::default() - }; - - // generate an ECC certificate - info!(" [Enclave] Generate ECC Certificate"); - let (key_der, cert_der) = match cert::gen_ecc_cert(&payload, &prv_k, &pub_k, &ecc_handle) { - Ok(r) => r, - Err(e) => { - error!(" [Enclave] gen_ecc_cert failed: {:?}", e); - return Err(e.into()) - }, - }; - - let _ = ecc_handle.close(); - info!(" [Enclave] Generate ECC Certificate successful"); - Ok((key_der, cert_der)) - } - - fn generate_dcap_ra_cert( - &self, - quoting_enclave_target_info: Option<&sgx_target_info_t>, - quote_size: Option<&u32>, - skip_ra: bool, - ) -> EnclaveResult<(Vec, Vec, Vec)> { - if !skip_ra && quoting_enclave_target_info.is_none() && quote_size.is_none() { - error!("Enclave Attestation] remote attestation not skipped, but Quoting Enclave (QE) data is not available"); - return Err(EnclaveError::Sgx(sgx_status_t::SGX_ERROR_UNEXPECTED)) - } - let chain_signer = self.signing_key_repo.retrieve_key()?; - info!("[Enclave Attestation] Ed25519 signer pub key: {:?}", chain_signer.public().0); - - let ecc_handle = SgxEccHandle::new(); - let _result = ecc_handle.open(); - let (prv_k, pub_k) = ecc_handle.create_key_pair()?; - info!("Enclave Attestation] Generated ephemeral ECDSA keypair:"); - debug!(" pubkey X is {:02x}", pub_k.gx.iter().format("")); - debug!(" pubkey Y is {:02x}", pub_k.gy.iter().format("")); - - let qe_quote = if !skip_ra { - let qe_quote = match self.retrieve_qe_dcap_quote( - &chain_signer.public().0, - quoting_enclave_target_info.unwrap(), - *quote_size.unwrap(), - ) { - Ok(quote) => quote, - Err(e) => { - error!("[Enclave] Error in create_dcap_attestation_report: {:?}", e); - return Err(e.into()) - }, - }; - qe_quote - } else { - Default::default() - }; - - let qe_quote_base_64 = base64::encode(&qe_quote[..]); - // generate an ECC certificate - debug!("[Enclave] Generate ECC Certificate"); - let (key_der, cert_der) = - match cert::gen_ecc_cert(&qe_quote_base_64, &prv_k, &pub_k, &ecc_handle) { - Ok(r) => r, - Err(e) => { - error!("[Enclave] gen_ecc_cert failed: {:?}", e); - return Err(e.into()) - }, - }; - - let _ = ecc_handle.close(); - - debug!("[Enclave] Generated ECC cert info:"); - trace!("[Enclave] Generated ECC cert info: key_der={:?}", &key_der); - trace!("[Enclave] Generated ECC cert info: cert_der={:?}", &cert_der); - trace!("[Enclave] Generated ECC cert info: qe_quote={:?}", &qe_quote); - Ok((key_der, cert_der, qe_quote)) - } -} - -impl IntelAttestationHandler { - pub fn new(ocall_api: Arc, signing_key_repo: Arc) -> Self { - Self { ocall_api, signing_key_repo } - } -} - -impl IntelAttestationHandler -where - OCallApi: EnclaveAttestationOCallApi, - AccessSigningKey: AccessKey, -{ - fn parse_response_attn_report(&self, resp: &[u8]) -> EnclaveResult<(String, String, String)> { - debug!(" [Enclave] Entering parse_response_attn_report"); - let mut headers = [httparse::EMPTY_HEADER; 16]; - let mut respp = httparse::Response::new(&mut headers); - let result = respp.parse(resp); - debug!(" [Enclave] respp.parse result {:?}", result); - - self.log_resp_code(&mut respp.code); - - let mut len_num: u32 = 0; - - let mut sig = String::new(); - let mut cert = String::new(); - let mut attn_report = String::new(); - - for i in 0..respp.headers.len() { - let h = respp.headers[i]; - //println!("{} : {}", h.name, str::from_utf8(h.value).unwrap()); - match h.name { - "Content-Length" => { - let len_str = String::from_utf8(h.value.to_vec()) - .map_err(|e| EnclaveError::Other(e.into()))?; - len_num = len_str.parse::().map_err(|e| EnclaveError::Other(e.into()))?; - debug!(" [Enclave] Content length = {}", len_num); - }, - "X-IASReport-Signature" => - sig = String::from_utf8(h.value.to_vec()) - .map_err(|e| EnclaveError::Other(e.into()))?, - "X-IASReport-Signing-Certificate" => - cert = String::from_utf8(h.value.to_vec()) - .map_err(|e| EnclaveError::Other(e.into()))?, - _ => (), - } - } - - // Remove %0A from cert, and only obtain the signing cert - cert = cert.replace("%0A", ""); - cert = cert::percent_decode(cert)?; - let v: Vec<&str> = cert.split("-----").collect(); - let sig_cert = v[2].to_string(); - - if len_num != 0 { - // The unwrap is safe. It resolves to the https::Status' unwrap function which only panics - // if the response is not complete, which cannot happen if the result is Ok(). - let header_len = result.map_err(|e| EnclaveError::Other(e.into()))?.unwrap(); - let resp_body = &resp[header_len..]; - attn_report = - String::from_utf8(resp_body.to_vec()).map_err(|e| EnclaveError::Other(e.into()))?; - debug!(" [Enclave] Attestation report = {}", attn_report); - } - - // len_num == 0 - Ok((attn_report, sig, sig_cert)) - } - - fn log_resp_code(&self, resp_code: &mut Option) { - let msg = match resp_code { - Some(200) => "OK, operation successful", - Some(400) => "Bad request, quote is invalid, or linkability of quote/subscription does not match.", - Some(401) => "Unauthorized, failed to authenticate or authorize request.", - Some(404) => "Not found, GID does not refer to a valid EPID group ID.", - Some(500) => "Internal error occurred.", - Some(503) => - "Service is currently not able to process the request (due to - a temporary overloading or maintenance). This is a - temporary state – the same request can be repeated after - some time.", - _ => { - error!("Error, received unknown HTTP response: {:?}", resp_code); - "Unknown error occured" - }, - }; - debug!(" [Enclave] msg = {}", msg); - } - - fn parse_response_sigrl(&self, resp: &[u8]) -> EnclaveResult> { - debug!(" [Enclave] Entering parse_response_sigrl"); - let mut headers = [httparse::EMPTY_HEADER; 16]; - let mut respp = httparse::Response::new(&mut headers); - let result = respp.parse(resp); - debug!(" [Enclave] Parse result {:?}", result); - debug!(" [Enclave] Parse response {:?}", respp); - - self.log_resp_code(&mut respp.code); - - let mut len_num: u32 = 0; - - for i in 0..respp.headers.len() { - let h = respp.headers[i]; - if h.name == "content-length" { - let len_str = String::from_utf8(h.value.to_vec()) - .map_err(|e| EnclaveError::Other(e.into()))?; - len_num = len_str.parse::().map_err(|e| EnclaveError::Other(e.into()))?; - debug!(" [Enclave] Content length = {}", len_num); - } - } - - if len_num != 0 { - // The unwrap is safe. It resolves to the https::Status' unwrap function which only panics - // if the response is not complete, which cannot happen if the result is Ok(). - let header_len = result.map_err(|e| EnclaveError::Other(e.into()))?.unwrap(); - let resp_body = &resp[header_len..]; - debug!(" [Enclave] Base64-encoded SigRL: {:?}", resp_body); - - let resp_str = str::from_utf8(resp_body).map_err(|e| EnclaveError::Other(e.into()))?; - return base64::decode(resp_str).map_err(|e| EnclaveError::Other(e.into())) - } - - // len_num == 0 - Ok(Vec::new()) - } - - fn make_ias_client_config() -> rustls::ClientConfig { - let mut config = rustls::ClientConfig::new(); - - config.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); - config - } - - fn get_sigrl_from_intel(&self, fd: c_int, gid: u32) -> EnclaveResult> { - debug!(" [Enclave] Entering get_sigrl_from_intel. fd = {:?}", fd); - let config = Self::make_ias_client_config(); - //let sigrl_arg = SigRLArg { group_id : gid }; - //let sigrl_req = sigrl_arg.to_httpreq(); - let ias_key = Self::get_ias_api_key()?; - - let req = format!("GET {}{:08x} HTTP/1.1\r\nHOST: {}\r\nOcp-Apim-Subscription-Key: {}\r\nConnection: Close\r\n\r\n", - SIGRL_SUFFIX, - gid, - DEV_HOSTNAME, - ias_key); - debug!(" [Enclave] request = {}", req); - - let dns_name = webpki::DNSNameRef::try_from_ascii_str(DEV_HOSTNAME) - .map_err(|e| EnclaveError::Other(e.into()))?; - let mut sess = rustls::ClientSession::new(&Arc::new(config), dns_name); - let mut sock = TcpStream::new(fd)?; - let mut tls = rustls::Stream::new(&mut sess, &mut sock); - - let _result = tls.write(req.as_bytes()); - let mut plaintext = Vec::new(); - - debug!(" [Enclave] tls.write complete"); - - tls.read_to_end(&mut plaintext)?; - - debug!(" [Enclave] tls.read_to_end complete"); - let resp_string = - String::from_utf8(plaintext.clone()).map_err(|e| EnclaveError::Other(e.into()))?; - - debug!(" [Enclave] resp_string = {}", resp_string); - - self.parse_response_sigrl(&plaintext) - } - - // TODO: support pse - fn get_report_from_intel( - &self, - fd: c_int, - quote: Vec, - ) -> EnclaveResult<(String, String, String)> { - debug!(" [Enclave] Entering get_report_from_intel. fd = {:?}", fd); - let config = Self::make_ias_client_config(); - let encoded_quote = base64::encode("e[..]); - let encoded_json = format!("{{\"isvEnclaveQuote\":\"{}\"}}\r\n", encoded_quote); - - let ias_key = Self::get_ias_api_key()?; - - let req = format!("POST {} HTTP/1.1\r\nHOST: {}\r\nOcp-Apim-Subscription-Key:{}\r\nContent-Length:{}\r\nContent-Type: application/json\r\nConnection: close\r\n\r\n{}", - REPORT_SUFFIX, - DEV_HOSTNAME, - ias_key, - encoded_json.len(), - encoded_json); - debug!(" [Enclave] Req = {}", req); - let dns_name = webpki::DNSNameRef::try_from_ascii_str(DEV_HOSTNAME).map_err(|e| { - error!("Invalid DEV_HOSTNAME"); - EnclaveError::Other(e.into()) - })?; - let mut sess = rustls::ClientSession::new(&Arc::new(config), dns_name); - let mut sock = TcpStream::new(fd)?; - let mut tls = rustls::Stream::new(&mut sess, &mut sock); - - let _result = tls.write(req.as_bytes()); - let mut plaintext = Vec::new(); - - debug!(" [Enclave] tls.write complete"); - - tls.read_to_end(&mut plaintext)?; - debug!(" [Enclave] tls.read_to_end complete"); - let resp_string = String::from_utf8(plaintext.clone()).map_err(|e| { - error!(" [Enclave] error decoding tls answer to string"); - EnclaveError::Other(e.into()) - })?; - - debug!(" [Enclave] resp_string = {}", resp_string); - - self.parse_response_attn_report(&plaintext) - } - - fn as_u32_le(&self, array: [u8; 4]) -> u32 { - u32::from(array[0]) - + (u32::from(array[1]) << 8) - + (u32::from(array[2]) << 16) - + (u32::from(array[3]) << 24) - } - - fn create_epid_attestation_report( - &self, - pub_k: &[u8; 32], - sign_type: sgx_quote_sign_type_t, - ) -> SgxResult<(String, String, String)> { - // Workflow: - // (1) ocall to get the target_info structure (ti) and epid group id (eg) - // (1.5) get sigrl - // (2) call sgx_create_report with ti+data, produce an sgx_report_t - // (3) ocall to sgx_get_quote to generate (*mut sgx-quote_t, uint32_t) - - // (1) get ti + eg - let init_quote = self.ocall_api.sgx_init_quote()?; - - let epid_group_id: sgx_epid_group_id_t = init_quote.1; - let target_info: sgx_target_info_t = init_quote.0; - - debug!(" [Enclave] EPID group id = {:?}", epid_group_id); - - let eg_num = self.as_u32_le(epid_group_id); - - // (1.5) get sigrl - let ias_socket = self.ocall_api.get_ias_socket()?; - - info!(" [Enclave] ias_sock = {}", ias_socket); - - // Now sigrl_vec is the revocation list, a vec - let sigrl_vec: Vec = self.get_sigrl_from_intel(ias_socket, eg_num)?; - - // (2) Generate the report - let mut report_data: sgx_report_data_t = sgx_report_data_t::default(); - report_data.d[..32].clone_from_slice(&pub_k[..]); - - let report = match rsgx_create_report(&target_info, &report_data) { - Ok(r) => { - debug!( - " [Enclave] Report creation successful. mr_signer.m = {:x?}", - r.body.mr_signer.m - ); - r - }, - Err(e) => { - error!(" [Enclave] Report creation failed. {:?}", e); - return Err(e) - }, - }; - - let mut quote_nonce = sgx_quote_nonce_t { rand: [0; 16] }; - let mut os_rng = os::SgxRng::new().map_err(|e| EnclaveError::Other(e.into()))?; - os_rng.fill_bytes(&mut quote_nonce.rand); - - // (3) Generate the quote - // Args: - // 1. sigrl: ptr + len - // 2. report: ptr 432bytes - // 3. linkable: u32, unlinkable=0, linkable=1 - // 4. spid: sgx_spid_t ptr 16bytes - // 5. sgx_quote_nonce_t ptr 16bytes - // 6. p_sig_rl + sigrl size ( same to sigrl) - // 7. [out]p_qe_report need further check - // 8. [out]p_quote - // 9. quote_size - - let spid: sgx_spid_t = Self::load_spid(RA_SPID_FILE)?; - - let quote_result = - self.ocall_api.get_quote(sigrl_vec, report, sign_type, spid, quote_nonce)?; - - let qe_report = quote_result.0; - let quote_content = quote_result.1; - - // Added 09-28-2018 - // Perform a check on qe_report to verify if the qe_report is valid - match rsgx_verify_report(&qe_report) { - Ok(()) => debug!(" [Enclave] rsgx_verify_report success!"), - Err(x) => { - error!(" [Enclave] rsgx_verify_report failed. {:?}", x); - return Err(x) - }, - } - - // Check if the qe_report is produced on the same platform - if target_info.mr_enclave.m != qe_report.body.mr_enclave.m - || target_info.attributes.flags != qe_report.body.attributes.flags - || target_info.attributes.xfrm != qe_report.body.attributes.xfrm - { - error!(" [Enclave] qe_report does not match current target_info!"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - debug!(" [Enclave] qe_report check success"); - - // Check qe_report to defend against replay attack - // The purpose of p_qe_report is for the ISV enclave to confirm the QUOTE - // it received is not modified by the untrusted SW stack, and not a replay. - // The implementation in QE is to generate a REPORT targeting the ISV - // enclave (target info from p_report) , with the lower 32Bytes in - // report.data = SHA256(p_nonce||p_quote). The ISV enclave can verify the - // p_qe_report and report.data to confirm the QUOTE has not be modified and - // is not a replay. It is optional. - - // need to call this a second time (first time is when we get the sigrl revocation list) - // (has some internal state that needs to be reset)! - let ias_socket = self.ocall_api.get_ias_socket()?; - - let mut rhs_vec: Vec = quote_nonce.rand.to_vec(); - rhs_vec.extend("e_content); - let rhs_hash = rsgx_sha256_slice(&rhs_vec[..])?; - let lhs_hash = &qe_report.body.report_data.d[..32]; - - debug!(" [Enclave] rhs hash = {:02X}", rhs_hash.iter().format("")); - debug!(" [Enclave] lhs hash = {:02X}", lhs_hash.iter().format("")); - - if rhs_hash != lhs_hash { - error!(" [Enclave] Quote is tampered!"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - let (attn_report, sig, cert) = self.get_report_from_intel(ias_socket, quote_content)?; - Ok((attn_report, sig, cert)) - } - - fn load_spid(filename: &str) -> SgxResult { - // Check if set as an environment variable - match env::var("IAS_EPID_SPID").or_else(|_| io::read_to_string(filename)) { - Ok(spid) => decode_spid(&spid), - Err(e) => { - error!("Failed to load SPID: {:?}", e); - Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - }, - } - } - - fn get_ias_api_key() -> EnclaveResult { - // Check if set as an environment variable - env::var("IAS_EPID_KEY") - .or_else(|_| io::read_to_string(RA_API_KEY_FILE)) - .map(|key| key.trim_end().to_owned()) - .map_err(|e| EnclaveError::Other(e.into())) - } - - /// Returns Ok if the verification of the quote by the quote verification enclave (QVE) was successful - pub fn ecdsa_quote_verification(&self, quote: Vec) -> SgxResult<()> { - let mut app_enclave_target_info: sgx_target_info_t = unsafe { std::mem::zeroed() }; - let quote_collateral: sgx_ql_qve_collateral_t = unsafe { std::mem::zeroed() }; - let mut qve_report_info: sgx_ql_qe_report_info_t = unsafe { std::mem::zeroed() }; - let supplemental_data_size = std::mem::size_of::() as u32; - - // Get target info of the app enclave. QvE will target the generated report to this enclave. - let ret_val = - unsafe { sgx_self_target(&mut app_enclave_target_info as *mut sgx_target_info_t) }; - if ret_val != sgx_status_t::SGX_SUCCESS { - error!("sgx_self_target returned: {:?}", ret_val); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - // Set current time, which is needed to check against the expiration date of the certificate. - let current_time: i64 = now_as_secs().try_into().unwrap_or_else(|e| { - panic!("Could not convert SystemTime from u64 into i64: {:?}", e); - }); - - // Set random nonce. - let mut rand_nonce = vec![0u8; 16]; - let ret_val = unsafe { sgx_read_rand(rand_nonce.as_mut_ptr(), rand_nonce.len()) }; - if ret_val != sgx_status_t::SGX_SUCCESS { - error!("sgx_read_rand returned: {:?}", ret_val); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - debug!("Retrieved random nonce {:?}", rand_nonce); - qve_report_info.nonce.rand.copy_from_slice(rand_nonce.as_slice()); - qve_report_info.app_enclave_target_info = app_enclave_target_info; - - // Ocall to call Quote verification Enclave (QvE), which verifies the generated quote. - let ( - collateral_expiration_status, - quote_verification_result, - qve_report_info_return_value, - supplemental_data, - ) = self.ocall_api.get_qve_report_on_quote( - quote.clone(), - current_time, - quote_collateral, - qve_report_info, - supplemental_data_size, - )?; - - // Check nonce of qve report to protect against replay attacks, as the qve report - // is coming from the untrusted side. - if qve_report_info_return_value.nonce.rand != qve_report_info.nonce.rand { - error!( - "Nonce of input value and return value are not matching. Input: {:?}, Output: {:?}", - qve_report_info.nonce.rand, qve_report_info_return_value.nonce.rand - ); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - // Set the threshold of QvE ISV SVN. The ISV SVN of QvE used to verify quote must be greater or equal to this threshold - // e.g. You can check latest QvE ISVSVN from QvE configuration file on Github - // https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/master/QuoteVerification/QvE/Enclave/linux/config.xml#L4 - // or you can get latest QvE ISVSVN in QvE Identity JSON file from - // https://api.trustedservices.intel.com/sgx/certification/v3/qve/identity - // Make sure you are using trusted & latest QvE ISV SVN as threshold - // Warning: The function may return erroneous result if QvE ISV SVN has been modified maliciously. - let qve_isvsvn_threshold: sgx_isv_svn_t = 6; - - // Verify the qve report to validate that it is coming from a legit quoting verification enclave - // and has not been tampered with. - let ret_val = unsafe { - sgx_tvl_verify_qve_report_and_identity( - quote.as_ptr(), - quote.len() as u32, - &qve_report_info_return_value as *const sgx_ql_qe_report_info_t, - current_time, - collateral_expiration_status, - quote_verification_result, - supplemental_data.as_ptr(), - supplemental_data_size, - qve_isvsvn_threshold, - ) - }; - - if ret_val != sgx_quote3_error_t::SGX_QL_SUCCESS { - error!("sgx_tvl_verify_qve_report_and_identity returned: {:?}", ret_val); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - Ok(()) - } - - pub fn retrieve_qe_dcap_quote( - &self, - pub_k: &[u8; 32], - quoting_enclave_target_info: &sgx_target_info_t, - quote_size: u32, - ) -> SgxResult> { - // Generate app enclave report and include the enclave public key. - // The quote will be generated on top of this report and validate that the - // report as well as the public key inside it are coming from a legit - // intel sgx enclave. - let mut report_data: sgx_report_data_t = sgx_report_data_t::default(); - report_data.d[..32].clone_from_slice(&pub_k[..]); - - let app_report = match rsgx_create_report(quoting_enclave_target_info, &report_data) { - Ok(report) => { - debug!( - "rsgx_create_report creation successful. mr_signer: {:?}", - report.body.mr_signer.m - ); - report - }, - Err(e) => { - error!("rsgx_create_report creation failed. {:?}", e); - return Err(e) - }, - }; - - // Retrieve quote from pccs for our app enclave. - debug!("Entering ocall_api.get_dcap_quote with quote size: {:?} ", quote_size); - let quote_vec = self.ocall_api.get_dcap_quote(app_report, quote_size)?; - - // Check mrenclave of quote, to ensure the quote has not been tampered with - // while being on the untrusted side. - // This step is probably obsolete, as the QvE will check the quote as well on behalf - // of the target enclave. - let p_quote3: *const sgx_quote3_t = quote_vec.as_ptr() as *const sgx_quote3_t; - let quote3: sgx_quote3_t = unsafe { *p_quote3 }; - if quote3.report_body.mr_enclave.m != app_report.body.mr_enclave.m { - error!("mr_enclave of quote and app_report are not matching"); - error!("mr_enclave of quote: {:?}", quote3.report_body.mr_enclave.m); - error!("mr_enclave of quote: {:?}", app_report.body.mr_enclave.m); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - Ok(quote_vec) - } -} - -fn decode_spid(hex_encoded_string: &str) -> SgxResult { - let mut spid = sgx_spid_t::default(); - let hex = hex_encoded_string.trim(); - - if hex.len() < itp_settings::files::SPID_MIN_LENGTH { - error!( - "Input spid length ({}) is incorrect, minimum length required is {}", - hex.len(), - itp_settings::files::SPID_MIN_LENGTH - ); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - let decoded_vec = hex::decode(hex).map_err(|_| sgx_status_t::SGX_ERROR_UNEXPECTED)?; - - spid.id.copy_from_slice(&decoded_vec[..16]); - Ok(spid) -} - -#[cfg(feature = "test")] -pub mod tests { - - use super::*; - - pub fn decode_spid_works() { - let spid_encoded = "F39ABCF95015A5BF6C7D360EF5035E12"; - let expected_spid = sgx_spid_t { - id: [243, 154, 188, 249, 80, 21, 165, 191, 108, 125, 54, 14, 245, 3, 94, 18], - }; - - let decoded_spid = decode_spid(spid_encoded).unwrap(); - assert_eq!(decoded_spid.id, expected_spid.id); - } -} diff --git a/tee-worker/bitacross/core-primitives/binary-merkle-tree/Cargo.toml b/tee-worker/bitacross/core-primitives/binary-merkle-tree/Cargo.toml deleted file mode 100644 index ab2acb0250..0000000000 --- a/tee-worker/bitacross/core-primitives/binary-merkle-tree/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "itp-binary-merkle-tree" -version = "0.8.0" -edition = "2021" - -[dependencies] -parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -binary-merkle-tree = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -std = [ - "parity-scale-codec/std", - "serde/std", - "binary-merkle-tree/std", -] diff --git a/tee-worker/bitacross/core-primitives/component-container/Cargo.toml b/tee-worker/bitacross/core-primitives/component-container/Cargo.toml deleted file mode 100644 index cb5d3b5541..0000000000 --- a/tee-worker/bitacross/core-primitives/component-container/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "itp-component-container" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - # sgx - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/bitacross/core-primitives/enclave-api/Cargo.toml b/tee-worker/bitacross/core-primitives/enclave-api/Cargo.toml index 707ebbe73b..f4277bee46 100644 --- a/tee-worker/bitacross/core-primitives/enclave-api/Cargo.toml +++ b/tee-worker/bitacross/core-primitives/enclave-api/Cargo.toml @@ -1,34 +1,32 @@ [package] -name = "itp-enclave-api" +name = "bc-itp-enclave-api" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -hex = "0.4" -log = "0.4" -serde_json = "1.0" -thiserror = "1.0.25" +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +log = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_urts = { optional = true, branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_crypto_helper = { workspace = true } +sgx_types = { workspace = true } +sgx_urts = { workspace = true, optional = true } -frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } -itc-parentchain = { path = "../../core/parentchain/parentchain-crate" } -itp-enclave-api-ffi = { path = "ffi" } -itp-settings = { path = "../settings" } -itp-sgx-crypto = { path = "../sgx/crypto" } -itp-stf-interface = { path = "../stf-interface" } -itp-storage = { path = "../storage" } -itp-types = { path = "../types" } +itp-enclave-api-ffi = { package = "bc-itp-enclave-api-ffi", path = "ffi" } +itp-settings = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-stf-interface = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } -# litentry -pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } +pallet-teebag = { workspace = true } [features] default = [] diff --git a/tee-worker/bitacross/core-primitives/enclave-api/ffi/Cargo.toml b/tee-worker/bitacross/core-primitives/enclave-api/ffi/Cargo.toml index 1e101deae5..1daa3ab730 100644 --- a/tee-worker/bitacross/core-primitives/enclave-api/ffi/Cargo.toml +++ b/tee-worker/bitacross/core-primitives/enclave-api/ffi/Cargo.toml @@ -1,12 +1,10 @@ [package] -name = "itp-enclave-api-ffi" +name = "bc-itp-enclave-api-ffi" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_types = { workspace = true } [features] # necessary to run cargo tests without any preliminaries diff --git a/tee-worker/bitacross/core-primitives/enclave-api/ffi/build.rs b/tee-worker/bitacross/core-primitives/enclave-api/ffi/build.rs index 766abb3eb4..09ccb3b707 100644 --- a/tee-worker/bitacross/core-primitives/enclave-api/ffi/build.rs +++ b/tee-worker/bitacross/core-primitives/enclave-api/ffi/build.rs @@ -24,7 +24,7 @@ fn main() { let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string()); // NOTE: if the crate is a workspace member rustc-paths are relative from the root directory - println!("cargo:rustc-link-search=native=./lib"); + println!("cargo:rustc-link-search=native=./bitacross/lib"); println!("cargo:rustc-link-lib=static=Enclave_u"); println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); diff --git a/tee-worker/bitacross/core-primitives/enclave-api/src/enclave_base.rs b/tee-worker/bitacross/core-primitives/enclave-api/src/enclave_base.rs index c5749a931d..d615895eff 100644 --- a/tee-worker/bitacross/core-primitives/enclave-api/src/enclave_base.rs +++ b/tee-worker/bitacross/core-primitives/enclave-api/src/enclave_base.rs @@ -19,10 +19,12 @@ use crate::EnclaveResult; use codec::Decode; use core::fmt::Debug; -use itc_parentchain::primitives::{ParentchainId, ParentchainInitParams}; use itp_sgx_crypto::{ecdsa, schnorr}; use itp_stf_interface::ShardCreationInfo; -use itp_types::{parentchain::Header, ShardIdentifier}; +use itp_types::{ + parentchain::{Header, ParentchainId, ParentchainInitParams}, + ShardIdentifier, +}; use pallet_teebag::EnclaveFingerprint; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use sp_core::ed25519; @@ -104,13 +106,15 @@ mod impl_ffi { use codec::{Decode, Encode}; use core::fmt::Debug; use frame_support::ensure; - use itc_parentchain::primitives::{ParentchainId, ParentchainInitParams}; use itp_enclave_api_ffi as ffi; use itp_settings::worker::{ HEADER_MAX_SIZE, MR_ENCLAVE_SIZE, SHIELDING_KEY_SIZE, SIGNING_KEY_SIZE, }; use itp_stf_interface::ShardCreationInfo; - use itp_types::{parentchain::Header, ShardIdentifier}; + use itp_types::{ + parentchain::{Header, ParentchainId, ParentchainInitParams}, + ShardIdentifier, + }; use log::*; use pallet_teebag::EnclaveFingerprint; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; diff --git a/tee-worker/bitacross/core-primitives/enclave-metrics/Cargo.toml b/tee-worker/bitacross/core-primitives/enclave-metrics/Cargo.toml deleted file mode 100644 index 4fc97c0b7c..0000000000 --- a/tee-worker/bitacross/core-primitives/enclave-metrics/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "itp-enclave-metrics" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# sgx -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] } - -[features] -default = ["std"] -std = [ - "codec/std", -] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/bitacross/core-primitives/enclave-metrics/src/lib.rs b/tee-worker/bitacross/core-primitives/enclave-metrics/src/lib.rs deleted file mode 100644 index 9d4f9b9355..0000000000 --- a/tee-worker/bitacross/core-primitives/enclave-metrics/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -extern crate core; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -use codec::{Decode, Encode}; -use core::time::Duration; - -#[derive(Encode, Decode, Debug)] -pub enum EnclaveMetric { - ParentchainBlockImportTime(Duration), - Musig2CeremonyStarted, - Musig2CeremonyFailed, - Musig2CeremonyTimedout(u8), - Musig2CeremonyDuration(Duration), -} diff --git a/tee-worker/bitacross/core-primitives/extrinsics-factory/Cargo.toml b/tee-worker/bitacross/core-primitives/extrinsics-factory/Cargo.toml deleted file mode 100644 index fcaa115701..0000000000 --- a/tee-worker/bitacross/core-primitives/extrinsics-factory/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "itp-extrinsics-factory" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# local dependencies -itp-node-api = { path = "../node-api", default-features = false } -itp-nonce-cache = { path = "../nonce-cache", default-features = false } -itp-types = { path = "../types", default-features = false } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "itp-node-api/std", - "itp-nonce-cache/std", - "itp-types/std", - "log/std", - "substrate-api-client/std", - "thiserror", -] -sgx = [ - "itp-node-api/sgx", - "itp-nonce-cache/sgx", - "sgx_tstd", - "thiserror_sgx", -] -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/extrinsics-factory/src/lib.rs b/tee-worker/bitacross/core-primitives/extrinsics-factory/src/lib.rs deleted file mode 100644 index 03e6ce732e..0000000000 --- a/tee-worker/bitacross/core-primitives/extrinsics-factory/src/lib.rs +++ /dev/null @@ -1,241 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -use codec::Encode; -use error::Result; -use itp_node_api::{ - api_client::{ - ExtrinsicParams, ParentchainAdditionalParams, ParentchainExtrinsicParams, SignExtrinsic, - }, - metadata::{provider::AccessNodeMetadata, NodeMetadata}, -}; -use itp_nonce_cache::{MutateNonce, Nonce}; -use itp_types::{parentchain::AccountId, OpaqueCall}; -use sp_core::H256; -use sp_runtime::{generic::Era, OpaqueExtrinsic}; -use std::{sync::Arc, vec::Vec}; -use substrate_api_client::ac_compose_macros::compose_extrinsic_offline; - -pub mod error; - -#[cfg(feature = "mocks")] -pub mod mock; - -/// Create extrinsics from opaque calls -/// -/// Also increases the nonce counter for each extrinsic that is created. -pub trait CreateExtrinsics { - fn create_extrinsics( - &self, - calls: &[OpaqueCall], - extrinsics_params: Option, - ) -> Result>; -} - -/// Extrinsics factory -pub struct ExtrinsicsFactory -where - Signer: SignExtrinsic, - NonceCache: MutateNonce, - NodeMetadataRepository: AccessNodeMetadata, -{ - genesis_hash: H256, - signer: Signer, - nonce_cache: Arc, - pub node_metadata_repository: Arc, -} - -impl - ExtrinsicsFactory -where - Signer: SignExtrinsic, - NonceCache: MutateNonce, - NodeMetadataRepository: AccessNodeMetadata, -{ - pub fn new( - genesis_hash: H256, - signer: Signer, - nonce_cache: Arc, - node_metadata_repository: Arc, - ) -> Self { - ExtrinsicsFactory { genesis_hash, signer, nonce_cache, node_metadata_repository } - } - - pub fn with_signer(&self, signer: Signer, nonce_cache: Arc) -> Self { - ExtrinsicsFactory { - genesis_hash: self.genesis_hash, - signer, - nonce_cache, - node_metadata_repository: self.node_metadata_repository.clone(), - } - } -} - -impl CreateExtrinsics - for ExtrinsicsFactory -where - Signer: SignExtrinsic, - NonceCache: MutateNonce, - NodeMetadataRepository: AccessNodeMetadata, -{ - fn create_extrinsics( - &self, - calls: &[OpaqueCall], - extrinsics_params: Option, - ) -> Result> { - let mut nonce_lock = self.nonce_cache.load_for_mutation()?; - let mut nonce_value = nonce_lock.0; - - let additional_extrinsic_params = extrinsics_params.unwrap_or_else(|| { - ParentchainAdditionalParams::new().era(Era::Immortal, self.genesis_hash).tip(0) - }); - - let (runtime_spec_version, runtime_transaction_version) = - self.node_metadata_repository.get_from_metadata(|m| { - (m.get_runtime_version(), m.get_runtime_transaction_version()) - })?; - - let extrinsics_buffer: Vec = calls - .iter() - .map(|call| { - log::info!("Creating extrinsics using nonce: {}", nonce_value); - let extrinsic_params = ParentchainExtrinsicParams::new( - runtime_spec_version, - runtime_transaction_version, - nonce_value, - self.genesis_hash, - additional_extrinsic_params, - ); - let xt = compose_extrinsic_offline!(&self.signer, call, extrinsic_params).encode(); - nonce_value += 1; - xt - }) - .map(|xt| { - OpaqueExtrinsic::from_bytes(&xt) - .expect("A previously encoded extrinsic has valid codec; qed.") - }) - .collect(); - - *nonce_lock = Nonce(nonce_value); - - Ok(extrinsics_buffer) - } -} - -#[cfg(test)] -pub mod tests { - - use super::*; - use itp_node_api::{ - api_client::{PairSignature, StaticExtrinsicSigner}, - metadata::provider::NodeMetadataRepository, - }; - use itp_nonce_cache::{GetNonce, Nonce, NonceCache, NonceValue}; - use sp_core::{ed25519, Pair}; - //use substrate_api_client::extrinsic::xt_primitives::UncheckedExtrinsicV4; - - #[test] - pub fn creating_xts_increases_nonce_for_each_xt() { - let nonce_cache = Arc::new(NonceCache::default()); - let node_metadata_repo = Arc::new(NodeMetadataRepository::new(NodeMetadata::default())); - let extrinsics_factory = ExtrinsicsFactory::new( - test_genesis_hash(), - StaticExtrinsicSigner::<_, PairSignature>::new(test_account()), - nonce_cache.clone(), - node_metadata_repo, - ); - - let opaque_calls = [OpaqueCall(vec![3u8; 42]), OpaqueCall(vec![12u8, 78])]; - let xts = extrinsics_factory.create_extrinsics(&opaque_calls, None).unwrap(); - - assert_eq!(opaque_calls.len(), xts.len()); - assert_eq!(nonce_cache.get_nonce().unwrap(), Nonce(opaque_calls.len() as NonceValue)); - } - - #[test] - pub fn with_signer_works() { - let nonce_cache1 = Arc::new(NonceCache::default()); - *nonce_cache1.load_for_mutation().unwrap() = Nonce(42); - - let node_metadata_repo = Arc::new(NodeMetadataRepository::new(NodeMetadata::default())); - let extrinsics_factory = ExtrinsicsFactory::new( - test_genesis_hash(), - StaticExtrinsicSigner::<_, PairSignature>::new(test_account()), - nonce_cache1.clone(), - node_metadata_repo, - ); - - let nonce_cache2 = Arc::new(NonceCache::default()); - let extrinsics_factory = extrinsics_factory.with_signer( - StaticExtrinsicSigner::<_, PairSignature>::new(test_account2()), - nonce_cache2.clone(), - ); - - let opaque_calls = [OpaqueCall(vec![3u8; 42]), OpaqueCall(vec![12u8, 78])]; - let xts = extrinsics_factory.create_extrinsics(&opaque_calls, None).unwrap(); - - assert_eq!(opaque_calls.len(), xts.len()); - assert_eq!(nonce_cache2.get_nonce().unwrap(), Nonce(opaque_calls.len() as NonceValue)); - assert_eq!(nonce_cache1.get_nonce().unwrap(), Nonce(42)); - } - - // #[test] - // pub fn xts_have_increasing_nonce() { - // let nonce_cache = Arc::new(NonceCache::default()); - // nonce_cache.set_nonce(Nonce(34)).unwrap(); - // let extrinsics_factory = - // ExtrinsicsFactory::new(test_genesis_hash(), test_account(), nonce_cache); - // - // let opaque_calls = - // [OpaqueCall(vec![3u8; 42]), OpaqueCall(vec![12u8, 78]), OpaqueCall(vec![15u8, 12])]; - // let xts: Vec> = extrinsics_factory - // .create_extrinsics(&opaque_calls) - // .unwrap() - // .iter() - // .map(|mut x| UncheckedExtrinsicV4::::decode(&mut x)) - // .collect(); - // - // assert_eq!(xts.len(), opaque_calls.len()); - // assert_eq!(xts[0].signature.unwrap().2 .2, 34u128); - // } - - fn test_account() -> ed25519::Pair { - ed25519::Pair::from_seed(b"42315678901234567890123456789012") - } - - fn test_account2() -> ed25519::Pair { - ed25519::Pair::from_seed(b"12315678901234567890123456789012") - } - - fn test_genesis_hash() -> H256 { - H256::from_slice(&[56u8; 32]) - } -} diff --git a/tee-worker/bitacross/core-primitives/extrinsics-factory/src/mock.rs b/tee-worker/bitacross/core-primitives/extrinsics-factory/src/mock.rs deleted file mode 100644 index 4e1923210e..0000000000 --- a/tee-worker/bitacross/core-primitives/extrinsics-factory/src/mock.rs +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, CreateExtrinsics}; -use itp_node_api::api_client::ParentchainAdditionalParams; -use itp_types::OpaqueCall; -use sp_runtime::OpaqueExtrinsic; -use std::vec::Vec; - -/// Mock of an extrinsics factory. To be used in unit tests. -/// -/// Returns an empty extrinsic. -#[derive(Default, Clone)] -pub struct ExtrinsicsFactoryMock; - -impl CreateExtrinsics for ExtrinsicsFactoryMock { - fn create_extrinsics( - &self, - _calls: &[OpaqueCall], - _additional_params: Option, - ) -> Result> { - // Intention was to map an OpaqueCall to some dummy OpaqueExtrinsic, - // so the output vector has the same size as the input one (and thus can be tested from the outside). - // However, it doesn't seem to be possible to construct an empty of dummy OpaqueExtrinsic, - // `from_bytes` expects a valid encoded OpaqueExtrinsic. - // Ok(calls - // .iter() - // .map(|_| OpaqueExtrinsic::from_bytes(Vec::new().as_slice()).unwrap()) - // .collect()) - Ok(Vec::new()) - } -} diff --git a/tee-worker/bitacross/core-primitives/hashing/Cargo.toml b/tee-worker/bitacross/core-primitives/hashing/Cargo.toml deleted file mode 100644 index e7a04918a1..0000000000 --- a/tee-worker/bitacross/core-primitives/hashing/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "itp-hashing" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [] diff --git a/tee-worker/bitacross/core-primitives/import-queue/Cargo.toml b/tee-worker/bitacross/core-primitives/import-queue/Cargo.toml deleted file mode 100644 index 2d358d8102..0000000000 --- a/tee-worker/bitacross/core-primitives/import-queue/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "itp-import-queue" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# crates.io std-only compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries - -[features] -default = ["std"] -std = [ - # no-std compatible libraries - # std compatible external libraries - "thiserror", -] -sgx = [ - # sgx - "sgx_tstd", - # sgx enabled external libraries - "thiserror_sgx", -] diff --git a/tee-worker/bitacross/core-primitives/networking-utils/Cargo.toml b/tee-worker/bitacross/core-primitives/networking-utils/Cargo.toml deleted file mode 100644 index 41032ef41d..0000000000 --- a/tee-worker/bitacross/core-primitives/networking-utils/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "itp-networking-utils" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - -] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/bitacross/core-primitives/node-api/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/Cargo.toml deleted file mode 100644 index c5ba3c9763..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "itp-node-api" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -itp-api-client-extensions = { optional = true, path = "api-client-extensions" } -itp-api-client-types = { default-features = false, path = "api-client-types" } -itp-node-api-factory = { optional = true, path = "factory" } -itp-node-api-metadata = { default-features = false, path = "metadata" } -itp-node-api-metadata-provider = { default-features = false, path = "metadata-provider" } - -[features] -default = ["std"] -std = [ - "itp-api-client-extensions", - "itp-api-client-types/std", - "itp-node-api-factory", - "itp-node-api-metadata/std", - "itp-node-api-metadata-provider/std", -] -sgx = [ - "itp-node-api-metadata-provider/sgx", -] -mocks = [ - "itp-node-api-metadata/mocks", -] diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/Cargo.toml deleted file mode 100644 index 45f0141dd2..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "itp-api-client-extensions" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] - -# substrate -sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# scs -# `default-features = false` to remove the jsonrpsee dependency. -substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# local deps -itp-api-client-types = { path = "../api-client-types" } -itp-types = { path = "../../types" } - -[features] -# used for unit testing only! -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-types/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/api-client-types/Cargo.toml deleted file mode 100644 index 9155bfac40..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/api-client-types/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "itp-api-client-types" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -itp-types = { default-features = false, path = "../../types" } -substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -[features] -default = ["std"] -std = [ - "itp-types/std", - "substrate-api-client/std", - "substrate-api-client/tungstenite-client", -] diff --git a/tee-worker/bitacross/core-primitives/node-api/factory/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/factory/Cargo.toml deleted file mode 100644 index edd4a821cb..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/factory/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "itp-node-api-factory" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -thiserror = { version = "1.0" } - -# substrate -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local -itp-api-client-types = { path = "../api-client-types" } diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata-provider/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/metadata-provider/Cargo.toml deleted file mode 100644 index 93ae23fcaa..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata-provider/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "itp-node-api-metadata-provider" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io - -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# sgx enabled external libraries -thiserror_sgx = { optional = true, package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# local dependencies -itp-node-api-metadata = { default-features = false, path = "../metadata" } -itp-stf-primitives = { default-features = false, path = "../../stf-primitives" } - -[features] -default = ["std"] -std = [ - "thiserror", - "itp-stf-primitives/std", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] -# used for unit testing only! -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/Cargo.toml b/tee-worker/bitacross/core-primitives/node-api/metadata/Cargo.toml deleted file mode 100644 index 22b93261cd..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "itp-node-api-metadata" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } - -# local -itp-api-client-types = { default-features = false, path = "../api-client-types" } -itp-stf-primitives = { default-features = false, path = "../../stf-primitives" } - -# substrate -sp-core = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-api-client-types/std", - "sp-core/std", - "itp-stf-primitives/std", -] - -# used for unit testing only! -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/lib.rs b/tee-worker/bitacross/core-primitives/node-api/metadata/src/lib.rs deleted file mode 100644 index 6db12fc320..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata/src/lib.rs +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Handle SGX compatible substrate chain metadata. - -#![cfg_attr(not(feature = "std"), no_std)] - -use crate::{ - error::Result, pallet_balances::BalancesCallIndexes, pallet_bitacross::BitAcrossCallIndexes, - pallet_proxy::ProxyCallIndexes, pallet_system::SystemSs58Prefix, - pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, - pallet_utility::UtilityCallIndexes, -}; -use codec::{Decode, Encode}; -use sp_core::storage::StorageKey; - -pub use crate::error::Error; -pub use itp_api_client_types::{Metadata, MetadataError}; - -pub mod error; -pub mod pallet_balances; -pub mod pallet_bitacross; -pub mod pallet_proxy; -pub mod pallet_system; -pub mod pallet_teebag; -pub mod pallet_utility; -pub mod runtime_call; - -pub mod pallet_timestamp; - -#[cfg(feature = "mocks")] -pub mod metadata_mocks; - -pub trait NodeMetadataTrait: - TeebagCallIndexes - + SystemSs58Prefix - + UtilityCallIndexes - + ProxyCallIndexes - + BalancesCallIndexes - + BitAcrossCallIndexes - + TimestampCallIndexes -{ -} -impl< - T: TeebagCallIndexes - + SystemSs58Prefix - + UtilityCallIndexes - + ProxyCallIndexes - + BalancesCallIndexes - + BitAcrossCallIndexes - + TimestampCallIndexes, - > NodeMetadataTrait for T -{ -} - -impl TryFrom for Metadata { - type Error = crate::error::Error; - - fn try_from(value: NodeMetadata) -> core::result::Result { - value.node_metadata.ok_or(Error::MetadataNotSet) - } -} - -#[derive(Default, Encode, Decode, Debug, Clone)] -pub struct NodeMetadata { - node_metadata: Option, - runtime_spec_version: u32, - runtime_transaction_version: u32, -} - -impl NodeMetadata { - pub fn new( - node_metadata: Metadata, - runtime_spec_version: u32, - runtime_transaction_version: u32, - ) -> Self { - Self { - node_metadata: Some(node_metadata), - runtime_spec_version, - runtime_transaction_version, - } - } - /// Return the substrate chain runtime version. - pub fn get_runtime_version(&self) -> u32 { - self.runtime_spec_version - } - - /// Return the substrate chain runtime transaction version. - pub fn get_runtime_transaction_version(&self) -> u32 { - self.runtime_transaction_version - } - - /// Generic call indexes: - /// Get the array [pallet index, call index] corresponding to a pallet's call over the metadata. - pub fn call_indexes( - &self, - pallet_name: &'static str, - call_name: &'static str, - ) -> Result<[u8; 2]> { - let pallet = match &self.node_metadata { - None => return Err(Error::MetadataNotSet), - Some(m) => m.pallet_by_name_err(pallet_name)?, - }; - let call_index = pallet - .call_variant_by_name(call_name) - .ok_or(Error::NodeMetadata(MetadataError::CallNotFound(call_name)))?; - Ok([pallet.index(), call_index.index]) - } - - /// Generic storages: - /// Get the storage keys corresponding to a storage over the metadata: - pub fn storage_value_key( - &self, - storage_prefix: &'static str, - storage_key_name: &'static str, - ) -> Result { - match &self.node_metadata { - None => Err(Error::MetadataNotSet), - Some(m) => m - .storage_value_key(storage_prefix, storage_key_name) - .map(|key| key.into()) - .map_err(Error::NodeMetadata), - } - } - - pub fn storage_map_key( - &self, - storage_prefix: &'static str, - storage_key_name: &'static str, - map_key: K, - ) -> Result { - match &self.node_metadata { - None => Err(Error::MetadataNotSet), - Some(m) => m - .storage_map_key::(storage_prefix, storage_key_name, map_key) - .map(|key| key.into()) - .map_err(Error::NodeMetadata), - } - } - - pub fn storage_double_map_key( - &self, - storage_prefix: &'static str, - storage_key_name: &'static str, - first: K, - second: Q, - ) -> Result { - match &self.node_metadata { - None => Err(Error::MetadataNotSet), - Some(m) => m - .storage_double_map_key(storage_prefix, storage_key_name, first, second) - .map(|key| key.into()) - .map_err(Error::NodeMetadata), - } - } -} diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/metadata_mocks.rs b/tee-worker/bitacross/core-primitives/node-api/metadata/src/metadata_mocks.rs deleted file mode 100644 index e3fcbc0e35..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata/src/metadata_mocks.rs +++ /dev/null @@ -1,236 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::Result, pallet_balances::BalancesCallIndexes, pallet_bitacross::BitAcrossCallIndexes, - pallet_proxy::ProxyCallIndexes, pallet_system::SystemSs58Prefix, - pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, - pallet_utility::UtilityCallIndexes, runtime_call::RuntimeCall, -}; -use codec::{Decode, Encode}; - -use itp_api_client_types::Metadata; - -impl TryFrom for Metadata { - type Error = (); - - fn try_from(_: NodeMetadataMock) -> core::result::Result { - Err(()) - } -} - -#[derive(Default, Encode, Decode, Debug, Clone)] -pub struct NodeMetadataMock { - // teebag - teebag_module: u8, - force_add_authorized_enclave: u8, - force_remove_authorized_enclave: u8, - register_enclave: u8, - unregister_enclave: u8, - register_quoting_enclave: u8, - register_tcb_info: u8, - post_opaque_task: u8, - parentchain_block_processed: u8, - sidechain_block_imported: u8, - - utility_module: u8, - utility_batch: u8, - utility_as_derivative: u8, - utility_batch_all: u8, - utility_dispatch_as: u8, - utility_force_batch: u8, - - imported_sidechain_block: u8, - proxy_module: u8, - add_proxy: u8, - proxy: u8, - balances_module: u8, - transfer: u8, - transfer_keep_alive: u8, - transfer_allow_death: u8, - timestamp_module: u8, - timestamp_set: u8, - runtime_spec_version: u32, - runtime_transaction_version: u32, - - bitacross_module: u8, - bitacross_add_relayer: u8, - bitacross_remove_relayer: u8, - btc_wallet_generated: u8, - eth_wallet_generated: u8, - ton_wallet_generated: u8, -} - -impl NodeMetadataMock { - pub fn new() -> Self { - NodeMetadataMock { - teebag_module: 50u8, - force_add_authorized_enclave: 0u8, - force_remove_authorized_enclave: 1u8, - register_enclave: 2u8, - unregister_enclave: 3u8, - register_quoting_enclave: 4u8, - register_tcb_info: 5u8, - post_opaque_task: 6u8, - parentchain_block_processed: 7u8, - sidechain_block_imported: 8u8, - - utility_module: 80u8, - utility_batch: 0u8, - utility_as_derivative: 1u8, - utility_batch_all: 2u8, - utility_dispatch_as: 3u8, - utility_force_batch: 4u8, - - imported_sidechain_block: 0u8, - proxy_module: 7u8, - add_proxy: 1u8, - proxy: 0u8, - balances_module: 10u8, - transfer: 7u8, - transfer_keep_alive: 3u8, - transfer_allow_death: 0u8, - timestamp_module: 3, - timestamp_set: 0, - runtime_spec_version: 25, - runtime_transaction_version: 4, - - bitacross_module: 69u8, - bitacross_add_relayer: 0u8, - bitacross_remove_relayer: 1u8, - btc_wallet_generated: 2u8, - eth_wallet_generated: 3u8, - ton_wallet_generated: 4u8, - } - } -} - -impl TeebagCallIndexes for NodeMetadataMock { - fn force_add_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.force_add_authorized_enclave]) - } - fn force_remove_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.force_remove_authorized_enclave]) - } - fn register_enclave_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.register_enclave]) - } - fn unregister_enclave_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.unregister_enclave]) - } - fn register_quoting_enclave_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.register_quoting_enclave]) - } - fn register_tcb_info_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.register_tcb_info]) - } - fn post_opaque_task_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.post_opaque_task]) - } - fn parentchain_block_processed_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.parentchain_block_processed]) - } - fn sidechain_block_imported_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.teebag_module, self.sidechain_block_imported]) - } -} - -impl UtilityCallIndexes for NodeMetadataMock { - fn batch_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.utility_module, self.utility_batch]) - } - - fn as_derivative_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.utility_module, self.utility_as_derivative]) - } - - fn batch_all_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.utility_module, self.utility_batch_all]) - } - - fn dispatch_as_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.utility_module, self.utility_dispatch_as]) - } - - fn force_batch_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.utility_module, self.utility_force_batch]) - } -} - -impl RuntimeCall for NodeMetadataMock { - fn retrieve(&self) -> Result { - Err(crate::Error::MetadataNotSet) - } -} - -impl SystemSs58Prefix for NodeMetadataMock { - fn system_ss58_prefix(&self) -> Result { - Ok(131) - } -} - -impl ProxyCallIndexes for NodeMetadataMock { - fn add_proxy_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.proxy_module, self.add_proxy]) - } - - fn proxy_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.proxy_module, self.proxy]) - } -} - -impl BalancesCallIndexes for NodeMetadataMock { - fn transfer_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.balances_module, self.transfer]) - } - - fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.balances_module, self.transfer_keep_alive]) - } - - fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.balances_module, self.transfer_allow_death]) - } -} - -impl BitAcrossCallIndexes for NodeMetadataMock { - fn add_relayer_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.bitacross_module, self.bitacross_add_relayer]) - } - - fn remove_relayer_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.bitacross_module, self.bitacross_remove_relayer]) - } - - fn btc_wallet_generated_indexes(&self) -> Result<[u8; 2]> { - Ok([self.bitacross_module, self.btc_wallet_generated]) - } - - fn eth_wallet_generated_indexes(&self) -> Result<[u8; 2]> { - Ok([self.bitacross_module, self.eth_wallet_generated]) - } - - fn ton_wallet_generated_indexes(&self) -> Result<[u8; 2]> { - Ok([self.bitacross_module, self.ton_wallet_generated]) - } -} - -impl TimestampCallIndexes for NodeMetadataMock { - fn timestamp_set_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.timestamp_module, self.timestamp_set]) - } -} diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_system.rs b/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_system.rs deleted file mode 100644 index 5005fdbecb..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_system.rs +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 Integritee AG and Supercomputing Systems AG -Licensed 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::{error::Result, Error, NodeMetadata}; -use codec::Decode; -use sp_core::storage::StorageKey; - -/// Pallet' name: -const SYSTEM: &str = "System"; - -pub trait SystemStorageIndexes { - fn system_account_storage_key(&self) -> Result; - - fn system_account_storage_map_key(&self, index: u64) -> Result; -} - -impl SystemStorageIndexes for NodeMetadata { - fn system_account_storage_key(&self) -> Result { - self.storage_value_key(SYSTEM, "Account") - } - - fn system_account_storage_map_key(&self, index: u64) -> Result { - self.storage_map_key(SYSTEM, "Account", index) - } -} - -// litentry -pub trait SystemSs58Prefix { - fn system_ss58_prefix(&self) -> Result; -} - -impl SystemSs58Prefix for NodeMetadata { - fn system_ss58_prefix(&self) -> Result { - match &self.node_metadata { - None => Err(Error::MetadataNotSet), - Some(meta_data) => { - let pallet = meta_data.pallet_by_name(SYSTEM).ok_or(Error::MetadataNotSet)?; - let mut raw = pallet.constant_by_name("SS58Prefix").unwrap().value.as_slice(); - u16::decode(&mut raw).map_err(|_| Error::InvalidMetadata) - }, - } - } -} diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_teebag.rs b/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_teebag.rs deleted file mode 100644 index ddd7cf062f..0000000000 --- a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_teebag.rs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2020-2024 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 crate::{error::Result, NodeMetadata}; - -/// Pallet' name: -pub const TEEBAG: &str = "Teebag"; - -// we only list the extrinsics that we care -pub trait TeebagCallIndexes { - fn force_add_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]>; - - fn force_remove_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]>; - - fn register_enclave_call_indexes(&self) -> Result<[u8; 2]>; - - fn unregister_enclave_call_indexes(&self) -> Result<[u8; 2]>; - - fn register_quoting_enclave_call_indexes(&self) -> Result<[u8; 2]>; - - fn register_tcb_info_call_indexes(&self) -> Result<[u8; 2]>; - - fn post_opaque_task_call_indexes(&self) -> Result<[u8; 2]>; - - fn parentchain_block_processed_call_indexes(&self) -> Result<[u8; 2]>; - - fn sidechain_block_imported_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl TeebagCallIndexes for NodeMetadata { - fn force_add_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "force_add_authorized_enclave") - } - fn force_remove_authorized_enclave_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "force_remove_authorized_enclave") - } - fn register_enclave_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "register_enclave") - } - fn unregister_enclave_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "unregister_enclave") - } - fn register_quoting_enclave_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "register_quoting_enclave") - } - fn register_tcb_info_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "register_tcb_info") - } - fn post_opaque_task_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "post_opaque_task") - } - fn parentchain_block_processed_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "parentchain_block_processed") - } - fn sidechain_block_imported_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TEEBAG, "sidechain_block_imported") - } -} diff --git a/tee-worker/bitacross/core-primitives/nonce-cache/Cargo.toml b/tee-worker/bitacross/core-primitives/nonce-cache/Cargo.toml deleted file mode 100644 index e7f3f012fb..0000000000 --- a/tee-worker/bitacross/core-primitives/nonce-cache/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "itp-nonce-cache" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local dependencies - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/bitacross/core-primitives/ocall-api/Cargo.toml b/tee-worker/bitacross/core-primitives/ocall-api/Cargo.toml deleted file mode 100644 index 0816ed4a88..0000000000 --- a/tee-worker/bitacross/core-primitives/ocall-api/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "itp-ocall-api" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } - -# sgx deps -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate deps -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-storage = { path = "../storage", default-features = false } -itp-types = { path = "../types", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "itp-storage/std", - "itp-types/std", -] diff --git a/tee-worker/bitacross/core-primitives/ocall-api/src/lib.rs b/tee-worker/bitacross/core-primitives/ocall-api/src/lib.rs deleted file mode 100644 index 2366dd00f1..0000000000 --- a/tee-worker/bitacross/core-primitives/ocall-api/src/lib.rs +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -pub extern crate alloc; - -use alloc::vec::Vec; -use codec::{Decode, Encode}; -use core::result::Result as StdResult; -use derive_more::{Display, From}; -use itp_storage::Error as StorageError; -use itp_types::{ - parentchain::ParentchainId, storage::StorageEntryVerified, TrustedOperationStatus, - WorkerRequest, WorkerResponse, -}; -use sgx_types::*; -use sp_core::H256; -use sp_runtime::{traits::Header, OpaqueExtrinsic}; -use sp_std::prelude::*; - -#[derive(Debug, Display, From)] -pub enum Error { - Storage(StorageError), - Codec(codec::Error), - Sgx(sgx_types::sgx_status_t), -} - -pub type Result = StdResult; -/// Trait for the enclave to make o-calls related to remote attestation -pub trait EnclaveAttestationOCallApi: Clone + Send + Sync { - fn sgx_init_quote(&self) -> SgxResult<(sgx_target_info_t, sgx_epid_group_id_t)>; - - fn get_ias_socket(&self) -> SgxResult; - - fn get_quote( - &self, - sig_rl: Vec, - report: sgx_report_t, - sign_type: sgx_quote_sign_type_t, - spid: sgx_spid_t, - quote_nonce: sgx_quote_nonce_t, - ) -> SgxResult<(sgx_report_t, Vec)>; - - fn get_dcap_quote(&self, report: sgx_report_t, quote_size: u32) -> SgxResult>; - - fn get_qve_report_on_quote( - &self, - quote: Vec, - current_time: i64, - quote_collateral: sgx_ql_qve_collateral_t, - qve_report_info: sgx_ql_qe_report_info_t, - supplemental_data_size: u32, - ) -> SgxResult<(u32, sgx_ql_qv_result_t, sgx_ql_qe_report_info_t, Vec)>; - - fn get_update_info( - &self, - platform_info: sgx_platform_info_t, - enclave_trusted: i32, - ) -> SgxResult; - - fn get_mrenclave_of_self(&self) -> SgxResult; -} - -/// trait for o-calls related to RPC -pub trait EnclaveRpcOCallApi: Clone + Send + Sync + Default { - fn update_status_event( - &self, - hash: H, - status_update: TrustedOperationStatus, - ) -> SgxResult<()>; - - fn send_state(&self, hash: H, value_opt: Option>) -> SgxResult<()>; -} - -/// trait for o-calls related to on-chain interactions -pub trait EnclaveOnChainOCallApi: Clone + Send + Sync { - fn send_to_parentchain( - &self, - extrinsics: Vec, - parentchain_id: &ParentchainId, - await_each_inclusion: bool, - ) -> SgxResult<()>; - - fn worker_request( - &self, - req: Vec, - parentchain_id: &ParentchainId, - ) -> SgxResult>>; - - fn get_storage_verified, V: Decode>( - &self, - storage_hash: Vec, - header: &H, - parentchain_id: &ParentchainId, - ) -> Result>; - - fn get_multiple_storages_verified, V: Decode>( - &self, - storage_hashes: Vec>, - header: &H, - parentchain_id: &ParentchainId, - ) -> Result>>; - - // Litentry - // given a key prefix, get all storage keys - fn get_storage_keys(&self, key_prefix: Vec) -> Result>>; -} - -/// Trait for sending metric updates. -pub trait EnclaveMetricsOCallApi: Clone + Send + Sync { - fn update_metric(&self, metric: Metric) -> SgxResult<()>; -} - -/// Newtype for IPFS CID -pub struct IpfsCid(pub [u8; 46]); - -/// trait for o-call related to IPFS -pub trait EnclaveIpfsOCallApi: Clone + Send + Sync { - fn write_ipfs(&self, encoded_state: &[u8]) -> SgxResult; - - fn read_ipfs(&self, cid: &IpfsCid) -> SgxResult<()>; -} diff --git a/tee-worker/bitacross/core-primitives/primitives-cache/Cargo.toml b/tee-worker/bitacross/core-primitives/primitives-cache/Cargo.toml deleted file mode 100644 index 09c1a30401..0000000000 --- a/tee-worker/bitacross/core-primitives/primitives-cache/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "itp-primitives-cache" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local dependencies - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/bitacross/core-primitives/primitives-cache/src/primitives_cache.rs b/tee-worker/bitacross/core-primitives/primitives-cache/src/primitives_cache.rs deleted file mode 100644 index 40bc516f51..0000000000 --- a/tee-worker/bitacross/core-primitives/primitives-cache/src/primitives_cache.rs +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLock as RwLock; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockReadGuard as RwLockReadGuard; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; - -#[cfg(feature = "std")] -use std::sync::RwLock; -#[cfg(feature = "std")] -use std::sync::RwLockReadGuard; -#[cfg(feature = "std")] -use std::sync::RwLockWriteGuard; - -use std::string::{String, ToString}; - -use crate::{ - error::{Error, Result}, - GetPrimitives, MutatePrimitives, Primitives, -}; - -/// Local primitives cache. -/// -/// Stores the primitives internally, protected by a RW lock for concurrent access. -#[derive(Default)] -pub struct PrimitivesCache { - primitives_lock: RwLock, -} - -impl PrimitivesCache { - pub fn new(primitives_lock: RwLock) -> Self { - PrimitivesCache { primitives_lock } - } -} - -impl MutatePrimitives for PrimitivesCache { - fn load_for_mutation(&self) -> Result> { - self.primitives_lock.write().map_err(|_| Error::LockPoisoning) - } -} - -impl GetPrimitives for PrimitivesCache { - fn get_primitives(&self) -> Result> { - self.primitives_lock.read().map_err(|_| Error::LockPoisoning) - } - - fn get_mu_ra_url(&self) -> Result { - let primitives_lock = self.primitives_lock.read().map_err(|_| Error::LockPoisoning)?; - Ok(primitives_lock.mu_ra_url().to_string()) - } - - fn get_untrusted_worker_url(&self) -> Result { - let primitives_lock = self.primitives_lock.read().map_err(|_| Error::LockPoisoning)?; - Ok(primitives_lock.untrusted_worker_url().to_string()) - } -} - -#[cfg(test)] -pub mod tests { - use super::*; - use std::{sync::Arc, thread}; - - #[test] - pub fn set_primitives_works() { - let cache = PrimitivesCache::default(); - let mut lock = cache.load_for_mutation().unwrap(); - let mu_ra_url = "hello".to_string(); - let untrusted_url = "world".to_string(); - let primitives = Primitives::new(mu_ra_url, untrusted_url); - *lock = primitives.clone(); - std::mem::drop(lock); - assert_eq!(primitives, *cache.get_primitives().unwrap()); - } - - #[test] - pub fn concurrent_read_access_blocks_until_write_is_done() { - let cache = Arc::new(PrimitivesCache::default()); - let mu_ra_url = "hello".to_string(); - let untrusted_url = "world".to_string(); - let primitives = Primitives::new(mu_ra_url, untrusted_url); - - let mut write_lock = cache.load_for_mutation().unwrap(); - - // Spawn a new thread that reads the primitives. - // This thread should be blocked until the write lock is released, i.e. until - // the new primitves are written. We can verify this, by trying to read the primitives variable - // that will be inserted further down below. - let new_thread_cache = cache.clone(); - let primitives_one = primitives.clone(); - let join_handle = thread::spawn(move || { - let read = new_thread_cache.get_primitives().unwrap(); - assert_eq!(primitives_one, *read); - }); - - *write_lock = primitives; - std::mem::drop(write_lock); - - join_handle.join().unwrap(); - } -} diff --git a/tee-worker/bitacross/core-primitives/rpc/Cargo.toml b/tee-worker/bitacross/core-primitives/rpc/Cargo.toml deleted file mode 100644 index 6db2e13890..0000000000 --- a/tee-worker/bitacross/core-primitives/rpc/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "itp-rpc" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -itp-types = { default-features = false, path = "../types" } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-types/std", - "serde/std", - "serde_json/std", -] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/bitacross/core-primitives/rpc/src/lib.rs b/tee-worker/bitacross/core-primitives/rpc/src/lib.rs deleted file mode 100644 index 75dfe4ffad..0000000000 --- a/tee-worker/bitacross/core-primitives/rpc/src/lib.rs +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -use codec::{Decode, Encode}; -use itp_types::DirectRequestStatus; -use serde::{Deserialize, Serialize}; -use std::{borrow::ToOwned, string::String, vec::Vec}; - -#[derive(Encode, Decode, Debug, Eq, PartialEq)] -pub struct RpcReturnValue { - pub value: Vec, - pub do_watch: bool, - pub status: DirectRequestStatus, -} -impl RpcReturnValue { - pub fn new(val: Vec, watch: bool, status: DirectRequestStatus) -> Self { - Self { value: val, do_watch: watch, status } - } - - pub fn from_error_message(error_msg: &str) -> Self { - RpcReturnValue { - value: error_msg.encode(), - do_watch: false, - status: DirectRequestStatus::Error, - } - } -} - -#[derive(Clone, Encode, Decode, Debug, Serialize, Deserialize, Eq, PartialEq, Hash)] -#[serde(untagged)] -pub enum Id { - #[codec(index = 0)] - Number(u32), - #[codec(index = 1)] - Text(String), -} - -#[derive(Clone, Encode, Decode, Debug, Serialize, Deserialize)] -pub struct RpcResponse { - pub jsonrpc: String, - pub result: String, // hex encoded RpcReturnValue - pub id: Id, -} - -#[derive(Clone, Encode, Decode, Serialize, Deserialize, Debug)] -pub struct RpcRequest { - pub jsonrpc: String, - pub method: String, - pub params: Vec, - pub id: Id, -} - -impl RpcRequest { - pub fn compose_jsonrpc_call( - id: Id, - method: String, - params: Vec, - ) -> Result { - serde_json::to_string(&RpcRequest { jsonrpc: "2.0".to_owned(), method, params, id }) - } -} - -#[cfg(test)] -pub mod tests { - use crate::Id; - - #[test] - pub fn deserialize_string_id() { - let id: Id = serde_json::from_str(r#""1""#).unwrap(); - assert!(matches!(id, Id::Text(t) if t == "1")) - } - - #[test] - pub fn deserialize_number_id() { - let id: Id = serde_json::from_str(r#"1"#).unwrap(); - assert!(matches!(id, Id::Number(t) if t == 1)) - } - - #[test] - pub fn serialize_string_id() { - let id = Id::Text("1".to_string()); - let serialized = serde_json::to_string(&id).unwrap(); - assert_eq!(serialized, r#""1""#) - } - - #[test] - pub fn serialize_number_id() { - let id = Id::Number(1); - let serialized = serde_json::to_string(&id).unwrap(); - assert_eq!(serialized, r#"1"#) - } -} diff --git a/tee-worker/bitacross/core-primitives/settings/src/lib.rs b/tee-worker/bitacross/core-primitives/settings/src/lib.rs deleted file mode 100644 index 9fab0b4adf..0000000000 --- a/tee-worker/bitacross/core-primitives/settings/src/lib.rs +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Common settings for the worker and the enclave. It is strictly `no_std` - -#![no_std] - -pub mod files { - // used by worker - pub static ENCLAVE_TOKEN: &str = "enclave.token"; - pub static ENCLAVE_FILE: &str = "enclave.signed.so"; - pub static SHIELDING_KEY_FILE: &str = "enclave-shielding-pubkey.json"; - pub static SIGNING_KEY_FILE: &str = "enclave-signing-pubkey.bin"; - - // used by enclave - /// Path to the light-client db for the Integritee parentchain. - pub const LITENTRY_PARENTCHAIN_LIGHT_CLIENT_DB_PATH: &str = "litentry_lcdb"; - - /// Path to the light-client db for the Target A parentchain. - pub const TARGET_A_PARENTCHAIN_LIGHT_CLIENT_DB_PATH: &str = "target_a_lcdb"; - - /// Path to the light-client db for the Target B parentchain. - pub const TARGET_B_PARENTCHAIN_LIGHT_CLIENT_DB_PATH: &str = "target_b_lcdb"; - - // bitacross - pub const RELAYER_REGISTRY_FILE: &str = "relayer_registry_sealed.bin"; - - pub const ENCLAVE_REGISTRY_FILE: &str = "enclave_registry_sealed.bin"; - - pub const SIGNER_REGISTRY_FILE: &str = "signer_registry_sealed.bin"; - - pub const RA_DUMP_CERT_DER_FILE: &str = "ra_dump_cert.der"; - - // used by worker and enclave - pub const SHARDS_PATH: &str = "shards"; - - #[cfg(not(feature = "development"))] - pub static RA_SPID_FILE: &str = "spid_production.txt"; - #[cfg(not(feature = "development"))] - pub static RA_API_KEY_FILE: &str = "key_production.txt"; - - #[cfg(feature = "development")] - pub static RA_SPID_FILE: &str = "spid.txt"; - #[cfg(feature = "development")] - pub static RA_API_KEY_FILE: &str = "key.txt"; - - pub const SPID_MIN_LENGTH: usize = 32; - pub const STATE_SNAPSHOTS_CACHE_SIZE: usize = 4; -} - -/// Settings concerning the worker -pub mod worker { - // the maximum size of any extrinsic that the enclave will ever generate in B - pub const EXTRINSIC_MAX_SIZE: usize = 13_000; - // the maximum size of the header - pub const HEADER_MAX_SIZE: usize = 512; - // maximum size of shielding key - pub const SHIELDING_KEY_SIZE: usize = 8192; - // maximum size of signing key - pub const SIGNING_KEY_SIZE: usize = 32; - // size of the MR enclave - pub const MR_ENCLAVE_SIZE: usize = 32; - // Should be set to a value that ensures that the enclave can register itself - // and that the worker can start. - pub const REGISTERING_FEE_FACTOR_FOR_INIT_FUNDS: u128 = 10; - // Should be set to a value that ensures that at least 2 sidechain blocks are finalized per - // parentchain block. - pub const BLOCK_NUMBER_FINALIZATION_DIFF: u64 = 20; -} - -pub mod sidechain { - use core::time::Duration; - - pub static SLOT_DURATION: Duration = Duration::from_millis(6000); -} diff --git a/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/Cargo.toml b/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/Cargo.toml deleted file mode 100644 index 510d51a270..0000000000 --- a/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "itp-sgx-runtime-primitives" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] - -# Substrate dependencies -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "frame-system/std", - "pallet-balances/std", - "sp-core/std", - "sp-runtime/std", -] diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/Cargo.toml b/tee-worker/bitacross/core-primitives/sgx/crypto/Cargo.toml deleted file mode 100644 index 0ed6ebf2fd..0000000000 --- a/tee-worker/bitacross/core-primitives/sgx/crypto/Cargo.toml +++ /dev/null @@ -1,59 +0,0 @@ -[package] -name = "itp-sgx-crypto" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -aes = { version = "0.6.0" } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -hex = { version = "0.4", default-features = false } -k256 = { version = "0.13.3", default-features = false, features = ["ecdsa-core", "schnorr", "alloc"] } -log = { version = "0.4", default-features = false } -ofb = { version = "0.4.0" } -secp256k1 = { version = "0.29.0", default-features = false, features = ["alloc", "recovery"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true } - -# sgx deps -serde_json-sgx = { package = "serde_json", tag = "sgx_1.1.3", git = "https://github.com/mesalock-linux/serde-json-sgx", optional = true } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-sgx-io = { path = "../io", default-features = false } - -# test sgx deps -itp-sgx-temp-dir = { default-features = false, optional = true, path = "../temp-dir" } - -[features] -default = ["std"] -std = [ - "codec/std", - "log/std", - "itp-sgx-io/std", - "sp-core/std", - "serde_json/std", - "sgx-crypto-helper/default", -] -sgx = [ - "sgx-crypto-helper/mesalock_sgx", - "sgx_tstd", - "sgx_rand", - "itp-sgx-io/sgx", - "serde_json-sgx", -] -mocks = [] -test = [ - # features - "mocks", - "sgx", - # deps - "itp-sgx-temp-dir", -] diff --git a/tee-worker/bitacross/core-primitives/sgx/io/Cargo.toml b/tee-worker/bitacross/core-primitives/sgx/io/Cargo.toml deleted file mode 100644 index 9c358d438b..0000000000 --- a/tee-worker/bitacross/core-primitives/sgx/io/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "itp-sgx-io" -version = "0.8.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - -# sgx deps -sgx_tstd = { optional = true, features = ["untrusted_fs"], branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -[features] -default = ["std"] -std = [] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/bitacross/core-primitives/stf-executor/Cargo.toml b/tee-worker/bitacross/core-primitives/stf-executor/Cargo.toml index 4b4f06df42..06d777cebf 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/Cargo.toml +++ b/tee-worker/bitacross/core-primitives/stf-executor/Cargo.toml @@ -1,57 +1,51 @@ [package] -name = "itp-stf-executor" +name = "bc-itp-stf-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } +hex = { workspace = true } -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["untrusted_time"] } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, features = ["untrusted_time"], optional = true } +sgx_types = { workspace = true } -# local dependencies -itp-node-api = { path = "../node-api", default-features = false } -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../substrate-sgx/externalities" } -itp-stf-interface = { path = "../stf-interface", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-stf-state-observer = { path = "../stf-state-observer", default-features = false } -itp-time-utils = { path = "../time-utils", default-features = false } -itp-top-pool-author = { path = "../top-pool-author", default-features = false } -itp-types = { path = "../types", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-node-api = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-stf-state-observer = { workspace = true } +itp-time-utils = { workspace = true } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../top-pool-author", default-features = false } +itp-types = { workspace = true } -# sgx enabled external libraries -thiserror_sgx = { optional = true, package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } # substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } # dev dependencies -itc-parentchain-test = { path = "../../core/parentchain/test", optional = true, default-features = false } -itp-test = { path = "../test", default-features = false, optional = true } +itc-parentchain-test = { workspace = true, optional = true } +itp-test = { workspace = true, optional = true } [dev-dependencies] -itp-stf-state-observer = { path = "../stf-state-observer", features = ["mocks"] } -itp-stf-interface = { path = "../stf-interface", features = ["mocks"] } -itp-top-pool = { path = "../top-pool", features = ["mocks"] } -itp-test = { path = "../test" } +itp-stf-state-observer = { workspace = true, features = ["std", "mocks"] } +itp-stf-interface = { workspace = true, features = ["std", "mocks"] } +itp-top-pool = { package = "bc-itp-top-pool", path = "../top-pool", features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } [features] default = ["std"] std = [ - # local "itp-node-api/std", "itp-ocall-api/std", "itp-sgx-crypto/std", @@ -62,10 +56,8 @@ std = [ "itp-top-pool-author/std", "itp-types/std", "itp-time-utils/std", - # crates.io "log/std", "codec/std", - # substrate "sp-core/std", "sp-runtime/std", "thiserror", diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/enclave_signer.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/enclave_signer.rs index 21264b381a..a4d4fd8c01 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/enclave_signer.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/enclave_signer.rs @@ -33,7 +33,6 @@ use itp_stf_primitives::{ use itp_stf_state_observer::traits::ObserveState; use itp_top_pool_author::traits::AuthorApi; use itp_types::{Index, MrEnclave, ShardIdentifier}; -use log::*; use sp_core::{ed25519::Pair as Ed25519Pair, Pair}; use std::{boxed::Box, sync::Arc, vec::Vec}; @@ -113,8 +112,7 @@ where G: PartialEq + Encode + Decode + Debug + Send + Sync, { fn get_enclave_account(&self) -> Result { - let enclave_call_signing_key = self.get_enclave_call_signing_key()?; - Ok(enclave_call_signing_key.public().into()) + self.get_enclave_call_signing_key().map(|key| key.public().into()) } fn get_mrenclave(&self) -> Result { @@ -147,11 +145,7 @@ where )) } - fn sign(&self, payload: &[u8]) -> Result<(AccountId, Vec)> { - let enclave_account = self.get_enclave_account()?; - let enclave_call_signing_key = self.get_enclave_call_signing_key()?; - - debug!(" [EnclaveSigner] VC pubkey: {:?}", enclave_call_signing_key.public().to_vec()); - Ok((enclave_account, enclave_call_signing_key.sign(payload).0.to_vec())) + fn sign(&self, payload: &[u8]) -> Result> { + self.get_enclave_call_signing_key().map(|key| key.sign(payload).0.to_vec()) } } diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/executor.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/executor.rs index 2138211243..ffc6d92fce 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/executor.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/executor.rs @@ -21,6 +21,7 @@ use crate::{ BatchExecutionResult, ExecutedOperation, }; use codec::{Decode, Encode}; +use itp_enclave_metrics::EnclaveMetric; use itp_node_api::metadata::{provider::AccessNodeMetadata, NodeMetadataTrait}; use itp_ocall_api::{EnclaveAttestationOCallApi, EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; use itp_sgx_externalities::{SgxExternalitiesTrait, StateHash}; @@ -42,8 +43,8 @@ use itp_types::{ use log::*; use sp_runtime::traits::Header as HeaderTrait; use std::{ - collections::BTreeMap, fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, vec, - vec::Vec, + collections::BTreeMap, fmt::Debug, marker::PhantomData, string::ToString, sync::Arc, + time::Duration, vec, vec::Vec, }; pub struct StfExecutor @@ -122,6 +123,7 @@ where } debug!("execute on STF, call with nonce {}", trusted_call.nonce()); + let mut extrinsic_call_backs: Vec = Vec::new(); return match Stf::execute_call( state, @@ -132,6 +134,12 @@ where self.node_metadata_repo.clone(), ) { Err(e) => { + if let Err(e) = + self.ocall_api.update_metric(EnclaveMetric::FailedTrustedOperationIncrement( + trusted_call.metric_name().to_string(), + )) { + warn!("Failed to update metric for failed trusted operations: {:?}", e); + } error!("Stf execute failed: {:?}", e); let rpc_response_value: Vec = e.encode(); Ok(ExecutedOperation::failed( @@ -142,8 +150,15 @@ where )) }, Ok(result) => { + if let Err(e) = self.ocall_api.update_metric( + EnclaveMetric::SuccessfulTrustedOperationIncrement( + trusted_call.metric_name().to_string(), + ), + ) { + warn!("Failed to update metric for succesfull trusted operations: {:?}", e); + } let force_connection_wait = result.force_connection_wait(); - let rpc_response_value: Vec = result.get_encoded_result(); + let rpc_response_value = result.get_encoded_result(); if let StatePostProcessing::Prune = post_processing { state.prune_state_diff(); } diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/executor_tests.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/executor_tests.rs index 458adc04b5..2eb0185bcd 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/executor_tests.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/executor_tests.rs @@ -32,7 +32,7 @@ use itp_types::H256; use sp_core::{ed25519, Pair}; use sp_runtime::app_crypto::sp_core::blake2_256; use std::{sync::Arc, time::Duration, vec}; -// FIXME: Create unit tests for update_states, execute_shield_funds, execute_trusted_call, execute_trusted_call_on_stf #554 +// FIXME: Create unit tests for update_states, execute_trusted_call, execute_trusted_call_on_stf #554 pub fn propose_state_update_executes_all_calls_given_enough_time() { // given diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/lib.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/lib.rs index 90e04cff44..6e1c8e21e8 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/lib.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/lib.rs @@ -81,15 +81,15 @@ impl ExecutionStatus { pub fn get_executed_operation_hash(&self) -> Option { match self { - ExecutionStatus::Success(operation_hash, _, _, _) => Some(*operation_hash), + ExecutionStatus::Success(operation_hash, ..) => Some(*operation_hash), _ => None, } } pub fn get_operation_hash(&self) -> H256 { match self { - ExecutionStatus::Success(operation_hash, _, _, _) => *operation_hash, - ExecutionStatus::Failure(operation_hash, _, _) => *operation_hash, + ExecutionStatus::Success(operation_hash, ..) => *operation_hash, + ExecutionStatus::Failure(operation_hash, ..) => *operation_hash, } } diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/mocks.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/mocks.rs index e0bc9c06e8..d328a2e24e 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/mocks.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/mocks.rs @@ -146,8 +146,8 @@ impl StfEnclaveSigning for StfEnclaveSigne Ok(trusted_call.sign(&KeyPair::Ed25519(Box::new(self.signer)), 1, &self.mr_enclave, shard)) } - fn sign(&self, _payload: &[u8]) -> Result<(AccountId, Vec)> { - Ok((self.signer.public().into(), [0u8; 32].to_vec())) + fn sign(&self, _payload: &[u8]) -> Result> { + Ok([0u8; 32].to_vec()) } } diff --git a/tee-worker/bitacross/core-primitives/stf-executor/src/traits.rs b/tee-worker/bitacross/core-primitives/stf-executor/src/traits.rs index ebfb9f0858..62e788141a 100644 --- a/tee-worker/bitacross/core-primitives/stf-executor/src/traits.rs +++ b/tee-worker/bitacross/core-primitives/stf-executor/src/traits.rs @@ -50,8 +50,8 @@ where shard: &ShardIdentifier, ) -> Result; - // litentry - fn sign(&self, payload: &[u8]) -> Result<(AccountId, Vec)>; + // litentry: sign an opaque payload + fn sign(&self, payload: &[u8]) -> Result>; } /// Proposes a state update to `Externalities`. diff --git a/tee-worker/bitacross/core-primitives/stf-interface/Cargo.toml b/tee-worker/bitacross/core-primitives/stf-interface/Cargo.toml deleted file mode 100644 index 1fc86aaed9..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-interface/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "itp-stf-interface" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } - -itp-node-api-metadata = { path = "../node-api/metadata", default-features = false, features = ["mocks"] } -itp-node-api-metadata-provider = { path = "../node-api/metadata-provider", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-types = { default-features = false, path = "../types" } - -[features] -default = ["std"] -std = [ - "itp-node-api-metadata/std", - "itp-node-api-metadata-provider/std", - "itp-stf-primitives/std", - "itp-types/std", -] -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/stf-primitives/Cargo.toml b/tee-worker/bitacross/core-primitives/stf-primitives/Cargo.toml deleted file mode 100644 index b127b2bc1d..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-primitives/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "itp-stf-primitives" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -derive_more = { version = "0.99.5" } -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - # crates.io - "codec/std", - # substrate - "sp-core/std", - "sp-std/std", - "sp-runtime/std", - "itp-sgx-runtime-primitives/std", - # litentry - "litentry-primitives/std", -] diff --git a/tee-worker/bitacross/core-primitives/stf-primitives/src/error.rs b/tee-worker/bitacross/core-primitives/stf-primitives/src/error.rs deleted file mode 100644 index 59130cfbfb..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-primitives/src/error.rs +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::types::{AccountId, Nonce}; -use alloc::string::String; -use codec::{Decode, Encode}; -use derive_more::Display; - -pub type StfResult = Result; - -#[derive(Debug, Display, PartialEq, Eq, Encode, Decode, Clone)] -pub enum StfError { - #[codec(index = 0)] - InvalidAccount, - - #[codec(index = 20)] - #[display(fmt = "Insufficient privileges {:?}, are you sure you are root?", _0)] - MissingPrivileges(AccountId), - #[codec(index = 11)] - #[display(fmt = "Valid enclave signer account is required")] - RequireEnclaveSignerAccount, - #[codec(index = 22)] - #[display(fmt = "Error dispatching runtime call. {:?}", _0)] - Dispatch(String), - #[codec(index = 23)] - #[display(fmt = "Not enough funds to perform operation")] - MissingFunds, - #[codec(index = 24)] - #[display(fmt = "Invalid Nonce {:?} != {:?}", _0, _1)] - InvalidNonce(Nonce, Nonce), - #[codec(index = 25)] - StorageHashMismatch, - #[codec(index = 26)] - InvalidStorageDiff, - #[codec(index = 27)] - InvalidMetadata, -} diff --git a/tee-worker/bitacross/core-primitives/stf-primitives/src/traits.rs b/tee-worker/bitacross/core-primitives/stf-primitives/src/traits.rs deleted file mode 100644 index 7193a5ea34..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-primitives/src/traits.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::types::{AccountId, KeyPair, ShardIdentifier}; -use alloc::vec::Vec; -use codec::{Decode, Encode}; -use core::fmt::Debug; -use itp_sgx_runtime_primitives::types::Index; -use litentry_primitives::Identity; -use sp_runtime::transaction_validity::{TransactionValidityError, ValidTransaction}; - -/// checks authorization of stf getters -pub trait GetterAuthorization { - fn is_authorized(&self) -> bool; -} - -/// knows how to sign a trusted call input and provides a signed output -pub trait TrustedCallSigning { - fn sign( - &self, - pair: &KeyPair, - nonce: Index, - mrenclave: &[u8; 32], - shard: &ShardIdentifier, - ) -> TCS; -} - -/// enables TrustedCallSigned verification -pub trait TrustedCallVerification { - fn sender_identity(&self) -> &Identity; - - fn nonce(&self) -> Index; - - fn verify_signature(&self, mrenclave: &[u8; 32], shard: &ShardIdentifier) -> bool; -} - -/// validation for top pool -pub trait PoolTransactionValidation { - fn validate(&self) -> Result; -} - -/// Trait to be implemented on the executor to serve helper methods of the executor -/// to the `IndirectDispatch` implementation. -pub trait IndirectExecutor -where - TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, -{ - fn submit_trusted_call(&self, shard: ShardIdentifier, encrypted_trusted_call: Vec); - - fn decrypt(&self, encrypted: &[u8]) -> Result, Error>; - - fn encrypt(&self, value: &[u8]) -> Result, Error>; - - fn get_enclave_account(&self) -> Result; - - fn get_default_shard(&self) -> ShardIdentifier; - - fn sign_call_with_self>( - &self, - trusted_call: &TC, - shard: &ShardIdentifier, - ) -> Result; - - fn get_relayer_registry_updater(&self) -> &RRU; - - fn get_signer_registry_updater(&self) -> &SRU; - - fn get_enclave_registry_updater(&self) -> &ERU; -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/Cargo.toml b/tee-worker/bitacross/core-primitives/stf-state-handler/Cargo.toml deleted file mode 100644 index 898f85423c..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/Cargo.toml +++ /dev/null @@ -1,72 +0,0 @@ -[package] -name = "itp-stf-state-handler" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# local dependencies -itp-hashing = { path = "../../core-primitives/hashing", default-features = false } -itp-settings = { path = "../../core-primitives/settings" } -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../../core-primitives/substrate-sgx/externalities" } -itp-sgx-io = { path = "../../core-primitives/sgx/io", default-features = false } -itp-stf-interface = { default-features = false, path = "../../core-primitives/stf-interface" } -itp-stf-state-observer = { path = "../stf-state-observer", default-features = false } -itp-time-utils = { path = "../../core-primitives/time-utils", default-features = false } -itp-types = { path = "../types", default-features = false } - -# for tests -itp-sgx-temp-dir = { version = "0.1", default-features = false, optional = true, path = "../../core-primitives/sgx/temp-dir" } - -# sgx enabled external libraries -rust-base58_sgx = { package = "rust-base58", rev = "sgx_1.1.3", git = "https://github.com/mesalock-linux/rust-base58-sgx", optional = true, default-features = false, features = ["mesalock_sgx"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -rust-base58 = { package = "rust-base58", version = "0.0.4", optional = true } -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[dev-dependencies] -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-state-observer = { path = "../stf-state-observer", features = ["mocks"] } -itp-hashing = { path = "../../core-primitives/hashing", features = ["std"] } - -[features] -default = ["std"] -std = [ - "rust-base58", - "itp-sgx-crypto/std", - "itp-sgx-externalities/std", - "itp-sgx-io/std", - "itp-stf-interface/std", - "itp-stf-state-observer/std", - "itp-time-utils/std", - "itp-types/std", - "thiserror", - "log/std", -] -sgx = [ - "sgx_tstd", - "rust-base58_sgx", - "itp-sgx-crypto/sgx", - "itp-sgx-externalities/sgx", - "itp-sgx-io/sgx", - "itp-stf-state-observer/sgx", - "itp-time-utils/sgx", - "thiserror_sgx", -] -test = [ - "itp-sgx-crypto/mocks", - "itp-stf-interface/mocks", - "itp-sgx-temp-dir", -] diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/file_io.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/file_io.rs deleted file mode 100644 index c0de994cb5..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/file_io.rs +++ /dev/null @@ -1,428 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -#[cfg(any(test, feature = "std"))] -use rust_base58::base58::{FromBase58, ToBase58}; - -#[cfg(feature = "sgx")] -use base58::{FromBase58, ToBase58}; - -#[cfg(any(test, feature = "sgx"))] -use std::string::String; - -use crate::{error::Result, state_snapshot_primitives::StateId}; -use codec::{Decode, Encode}; -// Todo: Can be migrated to here in the course of #1292. -use itp_settings::files::SHARDS_PATH; -use itp_types::ShardIdentifier; -use log::error; -use std::{ - format, - path::{Path, PathBuf}, - vec::Vec, -}; - -/// File name of the encrypted state file. -/// -/// It is also the suffix of all past snapshots. -pub const ENCRYPTED_STATE_FILE: &str = "state.bin"; - -/// Helps with file system operations of all files relevant for the State. -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct StateDir { - base_path: PathBuf, -} - -impl StateDir { - pub fn new(base_path: PathBuf) -> Self { - Self { base_path } - } - - pub fn shards_directory(&self) -> PathBuf { - self.base_path.join(SHARDS_PATH) - } - - pub fn shard_path(&self, shard: &ShardIdentifier) -> PathBuf { - self.shards_directory().join(shard.encode().to_base58()) - } - - pub fn list_shards(&self) -> Result> { - Ok(list_shards(&self.shards_directory()) - .map(|iter| iter.collect()) - // return an empty vec in case the directory does not exist. - .unwrap_or_default()) - } - - pub fn list_state_ids_for_shard( - &self, - shard_identifier: &ShardIdentifier, - ) -> Result> { - let shard_path = self.shard_path(shard_identifier); - Ok(state_ids_for_shard(shard_path.as_path())?.collect()) - } - - pub fn purge_shard_dir(&self, shard: &ShardIdentifier) { - let shard_dir_path = self.shard_path(shard); - if let Err(e) = std::fs::remove_dir_all(&shard_dir_path) { - error!("Failed to remove shard directory {:?}: {:?}", shard_dir_path, e); - } - } - - pub fn shard_exists(&self, shard: &ShardIdentifier) -> bool { - let shard_path = self.shard_path(shard); - shard_path.exists() && shard_contains_valid_state_id(&shard_path) - } - - pub fn create_shard(&self, shard: &ShardIdentifier) -> Result<()> { - Ok(std::fs::create_dir_all(self.shard_path(shard))?) - } - - pub fn state_file_path(&self, shard: &ShardIdentifier, state_id: StateId) -> PathBuf { - self.shard_path(shard).join(to_file_name(state_id)) - } - - pub fn file_for_state_exists(&self, shard: &ShardIdentifier, state_id: StateId) -> bool { - self.state_file_path(shard, state_id).exists() - } - - #[cfg(feature = "test")] - pub fn given_initialized_shard(&self, shard: &ShardIdentifier) { - if self.shard_exists(shard) { - self.purge_shard_dir(shard); - } - self.create_shard(&shard).unwrap() - } -} - -/// Trait to abstract file I/O for state. -pub trait StateFileIo { - type StateType; - type HashType; - - /// Load a state (returns error if it does not exist). - fn load( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result; - - /// Compute the state hash of a specific state (returns error if it does not exist). - /// - /// Requires loading and decoding of the state. Use only when loading the state repository on - /// initialization of the worker. Computing the state hash in other cases is the - /// StateHandler's responsibility. - fn compute_hash( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result; - - /// Initialize a new shard with a given state. - fn initialize_shard( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - state: &Self::StateType, - ) -> Result; - - /// Write the state. - fn write( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - state: &Self::StateType, - ) -> Result; - - /// Remove a state. - fn remove(&self, shard_identifier: &ShardIdentifier, state_id: StateId) -> Result<()>; - - /// Checks if a given shard directory exists and contains at least one state instance. - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool; - - /// Lists all shards. - fn list_shards(&self) -> Result>; - - /// List all states for a shard. - fn list_state_ids_for_shard(&self, shard_identifier: &ShardIdentifier) -> Result>; -} - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::*; - use crate::error::Error; - use codec::Decode; - use core::fmt::Debug; - use itp_hashing::Hash; - use itp_sgx_crypto::{key_repository::AccessKey, StateCrypto}; - use itp_sgx_externalities::SgxExternalitiesTrait; - use itp_sgx_io::{read as io_read, write as io_write}; - use itp_types::H256; - use log::*; - use std::{fs, marker::PhantomData, path::Path, sync::Arc}; - - /// SGX state file I/O. - pub struct SgxStateFileIo { - state_key_repository: Arc, - state_dir: StateDir, - _phantom: PhantomData, - } - - impl SgxStateFileIo - where - StateKeyRepository: AccessKey, - ::KeyType: StateCrypto, - State: SgxExternalitiesTrait, - { - pub fn new(state_key_repository: Arc, state_dir: StateDir) -> Self { - SgxStateFileIo { state_key_repository, state_dir, _phantom: PhantomData } - } - - fn read(&self, path: &Path) -> Result> { - let mut bytes = io_read(path)?; - - if bytes.is_empty() { - return Ok(bytes) - } - - let state_key = self.state_key_repository.retrieve_key()?; - - state_key - .decrypt(&mut bytes) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - trace!("buffer decrypted = {:?}", bytes); - - Ok(bytes) - } - - fn encrypt(&self, mut state: Vec) -> Result> { - let state_key = self.state_key_repository.retrieve_key()?; - - state_key - .encrypt(&mut state) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(state) - } - } - - impl StateFileIo for SgxStateFileIo - where - StateKeyRepository: AccessKey, - ::KeyType: StateCrypto, - State: SgxExternalitiesTrait + Hash + Debug, - ::SgxExternalitiesType: Encode + Decode, - { - type StateType = State; - type HashType = H256; - - fn load( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result { - if !self.state_dir.file_for_state_exists(shard_identifier, state_id) { - return Err(Error::InvalidStateId(state_id)) - } - - let state_path = self.state_dir.state_file_path(shard_identifier, state_id); - trace!("loading state from: {:?}", state_path); - let state_encoded = self.read(&state_path)?; - - // State is now decrypted. - debug!( - "State loaded from {:?} with size {}B, deserializing...", - state_path, - state_encoded.len() - ); - let state = ::SgxExternalitiesType::decode( - &mut state_encoded.as_slice(), - )?; - - trace!("state decoded successfully"); - // Add empty state-diff. - let state_with_diff = State::new(state); - trace!("New state created: {:?}", state_with_diff); - Ok(state_with_diff) - } - - fn compute_hash( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result { - let state = self.load(shard_identifier, state_id)?; - Ok(state.hash()) - } - - fn initialize_shard( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - state: &Self::StateType, - ) -> Result { - self.state_dir.create_shard(&shard_identifier)?; - self.write(shard_identifier, state_id, state) - } - - /// Writes the state (without the state diff) encrypted into the enclave storage. - /// Returns the hash of the saved state (independent of the diff!). - fn write( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - state: &Self::StateType, - ) -> Result { - let state_path = self.state_dir.state_file_path(shard_identifier, state_id); - trace!("writing state to: {:?}", state_path); - - // Only save the state, the state diff is pruned. - let cyphertext = self.encrypt(state.state().encode())?; - - let state_hash = state.hash(); - - io_write(&cyphertext, &state_path)?; - - Ok(state_hash) - } - - fn remove(&self, shard_identifier: &ShardIdentifier, state_id: StateId) -> Result<()> { - Ok(fs::remove_file(self.state_dir.state_file_path(shard_identifier, state_id))?) - } - - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool { - self.state_dir.shard_exists(shard_identifier) - } - - fn list_shards(&self) -> Result> { - self.state_dir.list_shards() - } - - fn list_state_ids_for_shard(&self, shard: &ShardIdentifier) -> Result> { - self.state_dir.list_state_ids_for_shard(shard) - } - } -} - -/// Lists all files with a valid state snapshot naming pattern. -pub(crate) fn state_ids_for_shard(shard_path: &Path) -> Result> { - Ok(items_in_directory(shard_path)?.filter_map(|item| { - match extract_state_id_from_file_name(&item) { - Some(state_id) => Some(state_id), - None => { - log::warn!( - "Found item ({}) that does not match state snapshot naming pattern, ignoring it", - item - ); - None - }, - } - })) -} - -/// Returns an iterator over all valid shards in a directory. -/// -/// Ignore any items (files, directories) that are not valid shard identifiers. -pub(crate) fn list_shards(path: &Path) -> Result> { - Ok(items_in_directory(path)?.filter_map(|base58| match shard_from_base58(&base58) { - Ok(shard) => Some(shard), - Err(e) => { - error!("Found invalid shard ({}). Error: {:?}", base58, e); - None - }, - })) -} - -fn shard_from_base58(base58: &str) -> Result { - let vec = base58.from_base58()?; - Ok(Decode::decode(&mut vec.as_slice())?) -} - -/// Returns an iterator over all filenames in a directory. -fn items_in_directory(directory: &Path) -> Result> { - Ok(directory - .read_dir()? - .filter_map(|fr| fr.ok().and_then(|de| de.file_name().into_string().ok()))) -} - -fn shard_contains_valid_state_id(path: &Path) -> bool { - // If at least on item can be decoded into a state id, the shard is not empty. - match state_ids_for_shard(path) { - Ok(mut iter) => iter.next().is_some(), - Err(e) => { - error!("Error in reading shard dir: {:?}", e); - false - }, - } -} - -fn to_file_name(state_id: StateId) -> String { - format!("{}_{}", state_id, ENCRYPTED_STATE_FILE) -} - -fn extract_state_id_from_file_name(file_name: &str) -> Option { - let state_id_str = file_name.strip_suffix(format!("_{}", ENCRYPTED_STATE_FILE).as_str())?; - state_id_str.parse::().ok() -} - -#[cfg(test)] -mod tests { - - use super::*; - use crate::state_snapshot_primitives::generate_current_timestamp_state_id; - - #[test] - fn state_id_to_file_name_works() { - assert!(to_file_name(generate_current_timestamp_state_id()).ends_with(ENCRYPTED_STATE_FILE)); - assert!(to_file_name(generate_current_timestamp_state_id()) - .strip_suffix(format!("_{}", ENCRYPTED_STATE_FILE).as_str()) - .is_some()); - - let now_time_stamp = generate_current_timestamp_state_id(); - assert_eq!( - extract_state_id_from_file_name(to_file_name(now_time_stamp).as_str()).unwrap(), - now_time_stamp - ); - } - - #[test] - fn extract_timestamp_from_file_name_works() { - assert_eq!( - 123456u128, - extract_state_id_from_file_name(format!("123456_{}", ENCRYPTED_STATE_FILE).as_str()) - .unwrap() - ); - assert_eq!( - 0u128, - extract_state_id_from_file_name(format!("0_{}", ENCRYPTED_STATE_FILE).as_str()) - .unwrap() - ); - - assert!(extract_state_id_from_file_name( - format!("987345{}", ENCRYPTED_STATE_FILE).as_str() - ) - .is_none()); - assert!( - extract_state_id_from_file_name(format!("{}", ENCRYPTED_STATE_FILE).as_str()).is_none() - ); - assert!(extract_state_id_from_file_name( - format!("1234_{}-other", ENCRYPTED_STATE_FILE).as_str() - ) - .is_none()); - } -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/handle_state.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/handle_state.rs deleted file mode 100644 index af0439d3cc..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/handle_state.rs +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; - -#[cfg(feature = "std")] -use std::sync::RwLockWriteGuard; - -use crate::error::Result; -use itp_types::ShardIdentifier; - -/// Facade for handling STF state loading and storing (e.g. from file). -pub trait HandleState { - type WriteLockPayload; - type StateT; - type HashType; - - /// Initialize a new shard. - /// - /// Initializes a default state for the shard and returns its hash. - fn initialize_shard(&self, shard: ShardIdentifier) -> Result; - - /// Execute a function that acts (immutably) on the current state. - /// - /// This allows access to the state, without any cloning. - fn execute_on_current(&self, shard: &ShardIdentifier, executing_function: E) -> Result - where - E: FnOnce(&Self::StateT, Self::HashType) -> R; - - /// Load a clone of the current state for a given shard. - /// - /// Requires the shard to exist and be initialized, otherwise returns an error. - /// Because it results in a clone, prefer using `execute_on_current` whenever possible. - fn load_cloned(&self, shard: &ShardIdentifier) -> Result<(Self::StateT, Self::HashType)>; - - /// Load the state in order to mutate it. - /// - /// Returns a write lock to protect against any concurrent access as long as - /// the lock is held. Finalize the operation by calling `write` and returning - /// the lock again. - fn load_for_mutation( - &self, - shard: &ShardIdentifier, - ) -> Result<(RwLockWriteGuard<'_, Self::WriteLockPayload>, Self::StateT)>; - - /// Writes the state (without the state diff) encrypted into the enclave. - /// - /// Returns the hash of the saved state (independent of the diff!). - fn write_after_mutation( - &self, - state: Self::StateT, - state_lock: RwLockWriteGuard<'_, Self::WriteLockPayload>, - shard: &ShardIdentifier, - ) -> Result; - - /// Reset (or override) a state. - /// - /// Use in cases where the previous state is of no interest. Otherwise use `load_for_mutation` and `write_after_mutation`. - fn reset(&self, state: Self::StateT, shard: &ShardIdentifier) -> Result; - - // litentry - fn migrate_shard(&self, new_shard: ShardIdentifier) -> Result; -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs deleted file mode 100644 index 702ccac0ab..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs +++ /dev/null @@ -1,418 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - file_io::StateFileIo, - state_snapshot_primitives::StateId, -}; -use codec::Encode; -use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesType}; -use itp_types::{ShardIdentifier, H256}; -use sp_core::blake2_256; -use std::{boxed::Box, collections::HashMap, sync::Arc, vec::Vec}; - -type StateHash = H256; -type ShardDirectory = HashMap; -type ShardsRootDirectory = HashMap>; -type InnerStateSelector = - Box State + Send + Sync + 'static>; -type ExternalStateGenerator = - Box ExternalState + Send + Sync + 'static>; - -/// State file I/O using (unencrypted) in-memory representation of the state files. -/// Can be used as mock for testing. -pub struct InMemoryStateFileIo -where - State: Clone + Default + Encode, -{ - emulated_shard_directory: RwLock>, - state_selector: InnerStateSelector, - external_state_generator: ExternalStateGenerator, -} - -impl InMemoryStateFileIo -where - State: Clone + Default + Encode, -{ - #[allow(unused)] - pub fn new( - shards: &[ShardIdentifier], - state_selector: InnerStateSelector, - external_state_generator: ExternalStateGenerator, - ) -> Self { - let shard_hash_map: HashMap<_, _> = - shards.iter().map(|s| (*s, ShardDirectory::::default())).collect(); - - InMemoryStateFileIo { - emulated_shard_directory: RwLock::new(shard_hash_map), - state_selector, - external_state_generator, - } - } - - #[cfg(any(test, feature = "test"))] - pub fn get_states_for_shard( - &self, - shard_identifier: &ShardIdentifier, - ) -> Result> { - let files_lock = self.emulated_shard_directory.read().map_err(|_| Error::LockPoisoning)?; - files_lock - .get(shard_identifier) - .cloned() - .ok_or_else(|| Error::InvalidShard(*shard_identifier)) - } - - fn compute_state_hash(&self, state: &State) -> StateHash { - let encoded_state = state.encode(); - blake2_256(&encoded_state).into() - } - - fn generate_state_entry(&self, state: State) -> (StateHash, State) { - let state_hash = self.compute_state_hash(&state); - (state_hash, state) - } -} - -impl StateFileIo for InMemoryStateFileIo -where - State: Clone + Default + Encode, -{ - type StateType = ExternalState; - type HashType = StateHash; - - fn load( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result { - let directory_lock = - self.emulated_shard_directory.read().map_err(|_| Error::LockPoisoning)?; - let states_for_shard = directory_lock - .get(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier))?; - let inner_state = states_for_shard - .get(&state_id) - .map(|(_, s)| -> State { s.clone() }) - .ok_or_else(|| Error::InvalidStateId(state_id))?; - - Ok((self.external_state_generator)(inner_state)) - } - - fn compute_hash( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - ) -> Result { - let state = self.load(shard_identifier, state_id)?; - Ok(self.compute_state_hash(&(self.state_selector)(&state))) - } - - fn initialize_shard( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - external_state: &Self::StateType, - ) -> Result { - let mut directory_lock = - self.emulated_shard_directory.write().map_err(|_| Error::LockPoisoning)?; - - let states_for_shard = directory_lock.entry(*shard_identifier).or_default(); - let state_entry = states_for_shard - .entry(state_id) - .or_insert_with(|| self.generate_state_entry((self.state_selector)(external_state))); - Ok(state_entry.0) - } - - fn write( - &self, - shard_identifier: &ShardIdentifier, - state_id: StateId, - external_state: &Self::StateType, - ) -> Result { - let mut directory_lock = - self.emulated_shard_directory.write().map_err(|_| Error::LockPoisoning)?; - - let states_for_shard = directory_lock.entry(*shard_identifier).or_default(); - - let inner_state = (self.state_selector)(external_state); - let state_hash = self.compute_state_hash(&inner_state); - - *states_for_shard.entry(state_id).or_default() = (state_hash, inner_state); - - Ok(state_hash) - } - - fn remove(&self, shard_identifier: &ShardIdentifier, state_id: StateId) -> Result<()> { - let mut directory_lock = - self.emulated_shard_directory.write().map_err(|_| Error::LockPoisoning)?; - - let states_for_shard = directory_lock - .get_mut(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier))?; - - states_for_shard - .remove(&state_id) - .ok_or_else(|| Error::InvalidStateId(state_id)) - .map(|_| {}) - } - - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool { - let directory_lock = self.emulated_shard_directory.read().unwrap(); - directory_lock.contains_key(shard_identifier) - } - - fn list_shards(&self) -> Result> { - let directory_lock = - self.emulated_shard_directory.read().map_err(|_| Error::LockPoisoning)?; - Ok(directory_lock.keys().copied().collect()) - } - - fn list_state_ids_for_shard(&self, shard_identifier: &ShardIdentifier) -> Result> { - let directory_lock = - self.emulated_shard_directory.read().map_err(|_| Error::LockPoisoning)?; - let shard_directory = directory_lock - .get(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier))?; - Ok(shard_directory.keys().cloned().collect()) - } -} - -pub fn create_sgx_externalities_in_memory_state_io( -) -> Arc> { - create_in_memory_externalities_state_io(&[]) -} - -fn create_in_memory_externalities_state_io( - shards: &[ShardIdentifier], -) -> Arc> { - Arc::new(InMemoryStateFileIo::new( - shards, - sgx_externalities_selector(), - sgx_externalities_wrapper(), - )) -} - -fn sgx_externalities_selector() -> InnerStateSelector { - Box::new(|s| s.state.clone()) -} - -fn sgx_externalities_wrapper() -> ExternalStateGenerator { - Box::new(|s| SgxExternalities { state: s, state_diff: Default::default() }) -} - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::*; - use crate::file_io::list_shards; - use std::path::Path; - - pub fn create_in_memory_state_io_from_shards_directories( - path: &Path, - ) -> Result>> { - let shards: Vec = - list_shards(path).map(|iter| iter.collect()).unwrap_or_default(); - Ok(create_in_memory_externalities_state_io(&shards)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::assert_matches::assert_matches; - - type TestState = u64; - type TestStateFileIo = InMemoryStateFileIo; - - #[test] - fn shard_directory_is_empty_after_initialization() { - let state_file_io = create_empty_in_memory_state_file_io(); - assert!(state_file_io.list_shards().unwrap().is_empty()); - } - - #[test] - fn load_on_empty_directory_and_shard_returns_error() { - let state_file_io = create_empty_in_memory_state_file_io(); - - assert_matches!( - state_file_io.load(&ShardIdentifier::random(), 1234), - Err(Error::InvalidShard(_)) - ); - } - - #[test] - fn initialize_with_shard_creates_empty_directory() { - let shard = ShardIdentifier::from([2u8; 32]); - let state_file_io = create_in_memory_state_file_io(&[shard]); - - assert!(state_file_io.list_state_ids_for_shard(&shard).unwrap().is_empty()); - assert!(state_file_io - .list_state_ids_for_shard(&ShardIdentifier::from([3u8; 32])) - .is_err()); - } - - #[test] - fn load_when_state_does_not_exist_returns_error() { - let state_file_io = create_empty_in_memory_state_file_io(); - let shard_id = ShardIdentifier::random(); - let _ = state_file_io.initialize_shard(&shard_id, 1234, &Default::default()).unwrap(); - - assert_matches!(state_file_io.load(&shard_id, 12345), Err(Error::InvalidStateId(12345))); - } - - #[test] - fn create_initialized_when_shard_already_exists_works() { - let shard = ShardIdentifier::random(); - let state_file_io = create_in_memory_state_file_io(&[shard]); - - assert!(state_file_io.initialize_shard(&shard, 1245, &Default::default()).is_ok()); - } - - #[test] - fn create_initialized_adds_default_state() { - let state_file_io = create_empty_in_memory_state_file_io(); - let shard_id = ShardIdentifier::random(); - let state_id = 31081984u128; - let state_hash = state_file_io - .initialize_shard(&shard_id, state_id, &Default::default()) - .unwrap(); - - assert_eq!(1, state_file_io.list_shards().unwrap().len()); - assert_eq!(TestState::default(), state_file_io.load(&shard_id, state_id).unwrap()); - assert_eq!(1, state_file_io.list_state_ids_for_shard(&shard_id).unwrap().len()); - - assert_entry(&state_file_io, &shard_id, state_id, &TestState::default(), &state_hash); - } - - #[test] - fn write_works_when_no_previous_shard_or_file_exists() { - let state_file_io = create_empty_in_memory_state_file_io(); - let shard_id = ShardIdentifier::random(); - let state_id = 23u128; - let test_state = 42u64; - - let state_hash = state_file_io.write(&shard_id, state_id, &test_state).unwrap(); - - assert_eq!(1, state_file_io.list_shards().unwrap().len()); - assert_eq!(test_state, state_file_io.load(&shard_id, state_id).unwrap()); - assert_eq!(1, state_file_io.list_state_ids_for_shard(&shard_id).unwrap().len()); - assert_entry(&state_file_io, &shard_id, state_id, &test_state, &state_hash); - } - - #[test] - fn write_overwrites_existing_state() { - let state_file_io = create_empty_in_memory_state_file_io(); - let shard_id = ShardIdentifier::random(); - let state_id = 123456u128; - let _ = state_file_io - .initialize_shard(&shard_id, state_id, &Default::default()) - .unwrap(); - - let test_state = 4256u64; - let state_hash = state_file_io.write(&shard_id, state_id, &test_state).unwrap(); - - assert_eq!(1, state_file_io.list_shards().unwrap().len()); - assert_eq!(test_state, state_file_io.load(&shard_id, state_id).unwrap()); - assert_eq!(1, state_file_io.list_state_ids_for_shard(&shard_id).unwrap().len()); - assert_entry(&state_file_io, &shard_id, state_id, &test_state, &state_hash); - } - - #[test] - fn remove_files_works() { - let state_file_io = create_empty_in_memory_state_file_io(); - let shard_id = ShardIdentifier::random(); - let initial_state_id = 42u128; - let _ = state_file_io - .initialize_shard(&shard_id, initial_state_id, &Default::default()) - .unwrap(); - - let state_ids = vec![1u128, 2u128, 3u128]; - - for state_id in state_ids.iter() { - let _ = state_file_io.write(&shard_id, *state_id, &987345).unwrap(); - } - - let mut expected_size = state_ids.len() + 1; - assert_eq!(expected_size, state_file_io.list_state_ids_for_shard(&shard_id).unwrap().len()); - expected_size -= 1; - - for state_id in state_ids.iter() { - state_file_io.remove(&shard_id, *state_id).unwrap(); - assert_matches!( - state_file_io.load(&shard_id, *state_id), - Err(Error::InvalidStateId(_)) - ); - assert_eq!( - expected_size, - state_file_io.list_state_ids_for_shard(&shard_id).unwrap().len() - ); - expected_size -= 1; - } - } - - #[test] - fn initialize_with_shards_creates_empty_maps() { - let shards = vec![ShardIdentifier::random(), ShardIdentifier::random()]; - let state_file_io = create_in_memory_state_file_io(shards.as_slice()); - - assert_eq!(shards.len(), state_file_io.list_shards().unwrap().len()); - for shard in shards { - assert!(state_file_io.list_state_ids_for_shard(&shard).unwrap().is_empty()); - } - } - - fn assert_entry( - state_file_io: &TestStateFileIo, - shard_id: &ShardIdentifier, - state_id: StateId, - state: &TestState, - state_hash: &StateHash, - ) { - let (retrieved_hash, retrieved_state) = - get_state_entry(&state_file_io, &shard_id, state_id); - assert!(state_file_io.shard_exists(shard_id)); - assert_eq!(state_hash, &retrieved_hash); - assert_eq!(state, &retrieved_state); - } - - fn get_state_entry( - state_file_io: &TestStateFileIo, - shard_id: &ShardIdentifier, - state_id: StateId, - ) -> (StateHash, TestState) { - state_file_io - .get_states_for_shard(shard_id) - .unwrap() - .get(&state_id) - .unwrap() - .clone() - } - - fn create_in_memory_state_file_io(shards: &[ShardIdentifier]) -> TestStateFileIo { - InMemoryStateFileIo::new(shards, Box::new(|x| *x), Box::new(|x| x)) - } - - fn create_empty_in_memory_state_file_io() -> TestStateFileIo { - create_in_memory_state_file_io(&[]) - } -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_handler.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_handler.rs deleted file mode 100644 index d662f2b6b3..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_handler.rs +++ /dev/null @@ -1,430 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::{SgxRwLock as RwLock, SgxRwLockWriteGuard as RwLockWriteGuard}; - -#[cfg(feature = "std")] -use std::sync::{RwLock, RwLockWriteGuard}; - -use crate::{ - error::{Error, Result}, - handle_state::HandleState, - query_shard_state::QueryShardState, - state_initializer::InitializeState, - state_snapshot_repository::VersionedStateAccess, -}; -use core::fmt::Debug; -use itp_hashing::Hash; -use itp_sgx_externalities::SgxExternalitiesTrait; -use itp_stf_state_observer::traits::UpdateState; -use itp_types::ShardIdentifier; -use log::{debug, trace}; -use std::{collections::HashMap, sync::Arc, vec::Vec}; - -type StatesMap = HashMap; - -/// Implementation of the `HandleState` trait. -/// -/// Responsible for handling any state instances. Holds a map with all the latest states for each shard. -/// In addition, uses the snapshot repository to save file snapshots of a state. -pub struct StateHandler -where - Repository: VersionedStateAccess, -{ - state_snapshot_repository: RwLock, - states_map_lock: RwLock>, - state_observer: Arc, - state_initializer: Arc, -} - -impl - StateHandler -where - Repository: VersionedStateAccess, - Repository::StateType: Hash, - StateObserver: UpdateState, - StateInitializer: InitializeState, -{ - /// Creates a new instance WITHOUT loading any state from the repository. - /// Results in an empty states map. - pub fn new( - state_snapshot_repository: Repository, - state_observer: Arc, - state_initializer: Arc, - ) -> Self { - Self::new_with_states_map( - state_snapshot_repository, - state_observer, - state_initializer, - Default::default(), - ) - } - - /// Create a new state handler and initialize its state map with the - /// states that are available in the snapshot repository. - pub fn load_from_repository( - state_snapshot_repository: Repository, - state_observer: Arc, - state_initializer: Arc, - ) -> Result { - let states_map = Self::load_all_latest_snapshots(&state_snapshot_repository)?; - Ok(Self::new_with_states_map( - state_snapshot_repository, - state_observer, - state_initializer, - states_map, - )) - } - - fn new_with_states_map( - state_snapshot_repository: Repository, - state_observer: Arc, - state_initializer: Arc, - states_map: StatesMap, - ) -> Self { - StateHandler { - state_snapshot_repository: RwLock::new(state_snapshot_repository), - states_map_lock: RwLock::new(states_map), - state_observer, - state_initializer, - } - } - - fn load_all_latest_snapshots( - state_snapshot_repository: &Repository, - ) -> Result> { - let shards = state_snapshot_repository.list_shards()?; - - let r = shards - .into_iter() - .map(|shard| state_snapshot_repository.load_latest(&shard).map(|state| (state, shard))) - // Fill the pairs for state and shard into a map. - // Log an error for cases where state could not be loaded. - .fold(StatesMap::default(), |mut map, x| { - match x { - Ok((state, shard)) => { - let state_hash = state.hash(); - map.insert(shard, (state, state_hash)); - }, - Err(e) => { - log::error!("Failed to load state from snapshot repository {:?}", e); - }, - }; - map - }); - - Ok(r) - } - - fn update_state_snapshot( - &self, - shard: &ShardIdentifier, - state: &Repository::StateType, - state_hash: Repository::HashType, - ) -> Result<()> { - let mut state_snapshots_lock = - self.state_snapshot_repository.write().map_err(|_| Error::LockPoisoning)?; - - state_snapshots_lock.update(shard, state, state_hash) - } -} - -impl HandleState - for StateHandler -where - Repository: VersionedStateAccess, - Repository::StateType: SgxExternalitiesTrait + Hash + Debug, - Repository::HashType: Copy, - StateObserver: UpdateState, - StateInitializer: InitializeState, -{ - type WriteLockPayload = StatesMap; - type StateT = Repository::StateType; - type HashType = Repository::HashType; - - fn initialize_shard(&self, shard: ShardIdentifier) -> Result { - let initialized_state = self.state_initializer.initialize()?; - self.reset(initialized_state, &shard) - } - - fn execute_on_current(&self, shard: &ShardIdentifier, executing_function: E) -> Result - where - E: FnOnce(&Self::StateT, Self::HashType) -> R, - { - self.states_map_lock - .read() - .map_err(|_| Error::LockPoisoning)? - .get(shard) - .map(|(state, state_hash)| executing_function(state, *state_hash)) - .ok_or_else(|| Error::InvalidShard(*shard)) - } - - fn load_cloned(&self, shard: &ShardIdentifier) -> Result<(Self::StateT, Self::HashType)> { - let state = self - .states_map_lock - .read() - .map_err(|_| Error::LockPoisoning)? - .get(shard) - .ok_or_else(|| Error::InvalidShard(*shard))? - .clone(); - - Ok(state) - } - - fn load_for_mutation( - &self, - shard: &ShardIdentifier, - ) -> Result<(RwLockWriteGuard<'_, Self::WriteLockPayload>, Self::StateT)> { - let state_write_lock = self.states_map_lock.write().map_err(|_| Error::LockPoisoning)?; - let state_clone = state_write_lock - .get(shard) - .ok_or_else(|| Error::InvalidShard(*shard))? - .0 - .clone(); - - Ok((state_write_lock, state_clone)) - } - - fn write_after_mutation( - &self, - mut state: Self::StateT, - mut state_lock: RwLockWriteGuard<'_, Self::WriteLockPayload>, - shard: &ShardIdentifier, - ) -> Result { - debug!("Writing state"); - trace!("State: {:?}", state); - state.prune_state_diff(); // Remove state diff before storing. - let state_hash = state.hash(); - // We create a state copy here, in order to serve the state observer. This does not scale - // well and we will want a better solution in the future, maybe with #459. - state_lock.insert(*shard, (state.clone(), state_hash)); - drop(state_lock); // Drop the write lock as early as possible. - - self.update_state_snapshot(shard, &state, state_hash)?; - - self.state_observer.queue_state_update(*shard, state)?; - Ok(state_hash) - } - - fn reset(&self, state: Self::StateT, shard: &ShardIdentifier) -> Result { - debug!("Resetting state"); - trace!("Resetting state: {:?}", state); - let state_write_lock = self.states_map_lock.write().map_err(|_| Error::LockPoisoning)?; - self.write_after_mutation(state, state_write_lock, shard) - } - - fn migrate_shard(&self, new_shard: ShardIdentifier) -> Result { - if self.shard_exists(&new_shard)? { - let (_, state_hash) = self.load_cloned(&new_shard)?; - return Ok(state_hash) - } - let old_shard = match self.list_shards()? { - shards if shards.len() == 1 => shards[0], - _ => - return Err(Error::Other( - "Cannot migrate shard if there is more than one shard".into(), - )), - }; - let (state, _) = self.load_cloned(&old_shard)?; - self.reset(state, &new_shard) - } -} - -impl QueryShardState - for StateHandler -where - Repository: VersionedStateAccess, - Repository::StateType: Hash, - StateObserver: UpdateState, - StateInitializer: InitializeState, -{ - fn shard_exists(&self, shard: &ShardIdentifier) -> Result { - let states_map_lock = self.states_map_lock.read().map_err(|_| Error::LockPoisoning)?; - Ok(states_map_lock.contains_key(shard)) - } - - fn list_shards(&self) -> Result> { - let states_map_lock = self.states_map_lock.read().map_err(|_| Error::LockPoisoning)?; - Ok(states_map_lock.keys().cloned().collect()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test::mocks::{ - initialize_state_mock::InitializeStateMock, - versioned_state_access_mock::VersionedStateAccessMock, - }; - use codec::Encode; - use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesType}; - use itp_stf_state_observer::mock::UpdateStateMock; - use itp_types::H256; - use std::{collections::VecDeque, sync::Arc, thread}; - - type TestState = SgxExternalities; - type TestHash = H256; - type TestStateRepository = VersionedStateAccessMock; - type TestStateObserver = UpdateStateMock; - type TestStateInitializer = InitializeStateMock; - type TestStateHandler = - StateHandler; - - fn create_state(content: u64) -> TestState { - let mut state = TestState::new(SgxExternalitiesType::default()); - state.insert("key_1".encode(), content.encode()); - state - } - - fn create_state_without_diff(content: u64) -> TestState { - let state = create_state(content); - prune_diff(state) - } - - fn prune_diff(mut state: TestState) -> TestState { - state.prune_state_diff(); - state - } - - #[test] - fn load_for_mutation_blocks_any_concurrent_access() { - let shard_id = ShardIdentifier::random(); - let state_handler = default_state_handler(); - state_handler.initialize_shard(shard_id).unwrap(); - - let (lock, _s) = state_handler.load_for_mutation(&shard_id).unwrap(); - - let state_handler_clone = state_handler.clone(); - let join_handle = thread::spawn(move || { - let (latest_state, _) = state_handler_clone.load_cloned(&shard_id).unwrap(); - assert_eq!(create_state_without_diff(4u64), latest_state); - }); - - let _hash = - state_handler.write_after_mutation(create_state(4u64), lock, &shard_id).unwrap(); - - join_handle.join().unwrap(); - } - - #[test] - fn write_and_reset_queue_observer_update() { - let shard_id = ShardIdentifier::default(); - let state_observer = Arc::new(TestStateObserver::default()); - let state_initializer = Arc::new(TestStateInitializer::new(Default::default())); - let state_handler = Arc::new(TestStateHandler::new( - default_repository(), - state_observer.clone(), - state_initializer, - )); - state_handler.initialize_shard(shard_id).unwrap(); - - let (lock, _s) = state_handler.load_for_mutation(&shard_id).unwrap(); - let new_state = create_state(4u64); - state_handler.write_after_mutation(new_state.clone(), lock, &shard_id).unwrap(); - - let reset_state = create_state(5u64); - state_handler.reset(reset_state.clone(), &shard_id).unwrap(); - - let observer_updates = state_observer.queued_updates.read().unwrap().clone(); - assert_eq!(3, observer_updates.len()); - assert_eq!((shard_id, prune_diff(new_state)), observer_updates[1]); - assert_eq!((shard_id, prune_diff(reset_state)), observer_updates[2]); - } - - #[test] - fn load_initialized_works() { - let shard_id = ShardIdentifier::random(); - let state_handler = default_state_handler(); - state_handler.initialize_shard(shard_id).unwrap(); - assert!(state_handler.load_cloned(&shard_id).is_ok()); - assert!(state_handler.load_cloned(&ShardIdentifier::random()).is_err()); - } - - #[test] - fn list_shards_works() { - let shard_id = ShardIdentifier::random(); - let state_handler = default_state_handler(); - state_handler.initialize_shard(shard_id).unwrap(); - assert_eq!(1, state_handler.list_shards().unwrap().len()); - } - - #[test] - fn shard_exists_works() { - let shard_id = ShardIdentifier::random(); - let state_handler = default_state_handler(); - state_handler.initialize_shard(shard_id).unwrap(); - assert!(state_handler.shard_exists(&shard_id).unwrap()); - assert!(!state_handler.shard_exists(&ShardIdentifier::random()).unwrap()); - } - - #[test] - fn load_from_repository_works() { - let state_observer = Arc::new(TestStateObserver::default()); - let state_initializer = Arc::new(TestStateInitializer::new(Default::default())); - - let repository = TestStateRepository::new(HashMap::from([ - ( - ShardIdentifier::from([1u8; 32]), - VecDeque::from([create_state(3), create_state(2), create_state(1)]), - ), - (ShardIdentifier::from([2u8; 32]), VecDeque::from([create_state(5)])), - (ShardIdentifier::from([3u8; 32]), VecDeque::new()), - ])); - - assert_eq!(3, repository.list_shards().unwrap().len()); - assert!(repository.load_latest(&ShardIdentifier::from([3u8; 32])).is_err()); - - let state_handler = - TestStateHandler::load_from_repository(repository, state_observer, state_initializer) - .unwrap(); - - assert_eq!( - 2, - state_handler.list_shards().unwrap().len(), - "Only 2 shards, not 3, because 3rd was empty" - ); - } - - #[test] - fn ensure_state_diff_is_discarded() { - let shard_id = ShardIdentifier::random(); - let state_handler = default_state_handler(); - - let state = create_state(3u64); - let state_without_diff = { - let mut state_clone = state.clone(); - state_clone.prune_state_diff(); - state_clone - }; - - state_handler.reset(state, &shard_id).unwrap(); - let (loaded_state, _) = state_handler.load_cloned(&shard_id).unwrap(); - - assert_eq!(state_without_diff, loaded_state); - } - - fn default_state_handler() -> Arc { - let state_observer = Arc::new(TestStateObserver::default()); - let state_initializer = Arc::new(TestStateInitializer::new(Default::default())); - Arc::new(TestStateHandler::new(default_repository(), state_observer, state_initializer)) - } - - fn default_repository() -> TestStateRepository { - TestStateRepository::default() - } -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_repository.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_repository.rs deleted file mode 100644 index 1b60a88741..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_repository.rs +++ /dev/null @@ -1,484 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::{Error, Result}, - file_io::StateFileIo, - state_snapshot_primitives::{ - generate_current_timestamp_state_id, initialize_shard_with_snapshot, SnapshotHistory, - StateId, StateSnapshotMetaData, - }, -}; -use core::ops::RangeBounds; -use itp_types::ShardIdentifier; -use log::*; -use std::{collections::VecDeque, fmt::Debug, format, sync::Arc, vec::Vec}; - -/// Trait for versioned state access. Manages history of state snapshots. -pub trait VersionedStateAccess { - type StateType: Clone; - type HashType; - - /// Load the latest version of the state. - fn load_latest(&self, shard_identifier: &ShardIdentifier) -> Result; - - /// Update the state, returning the hash of the state. - fn update( - &mut self, - shard_identifier: &ShardIdentifier, - state: &Self::StateType, - state_hash: Self::HashType, - ) -> Result<()>; - - /// Reverts the state of a given shard to a state version identified by a state hash. - fn revert_to( - &mut self, - shard_identifier: &ShardIdentifier, - state_hash: &Self::HashType, - ) -> Result; - - /// Initialize a new shard. - /// - /// If the shard already exists, it will re-initialize it. - fn initialize_new_shard( - &mut self, - shard_identifier: ShardIdentifier, - state: &Self::StateType, - ) -> Result; - - /// Checks if a shard for a given identifier exists. - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool; - - /// Lists all shards. - fn list_shards(&self) -> Result>; -} - -/// State snapshot repository. -/// -/// Keeps versions of state snapshots, cycles them in a fixed-size circular buffer. -/// Creates a state snapshot for each write/update operation. Allows reverting to a specific snapshot, -/// identified by a state hash. Snapshot files names includes a timestamp to be unique. -pub struct StateSnapshotRepository -where - FileIo: StateFileIo, - ::HashType: Copy + Eq + Debug, - ::StateType: Clone, -{ - file_io: Arc, - snapshot_history_cache_size: usize, - snapshot_history: SnapshotHistory, -} - -impl StateSnapshotRepository -where - FileIo: StateFileIo, - ::HashType: Copy + Eq + Debug, - ::StateType: Clone, -{ - /// Constructor, initialized with no shards or snapshot history. - pub fn empty(file_io: Arc, snapshot_history_cache_size: usize) -> Result { - Self::new(file_io, snapshot_history_cache_size, SnapshotHistory::default()) - } - - /// Constructor to initialize the repository with shards and snapshot history. - /// - /// Crate private, to be used by the loader. - pub(crate) fn new( - file_io: Arc, - snapshot_history_cache_size: usize, - snapshot_history: SnapshotHistory, - ) -> Result { - if snapshot_history_cache_size == 0usize { - return Err(Error::ZeroCacheSize) - } - - Ok(StateSnapshotRepository { file_io, snapshot_history_cache_size, snapshot_history }) - } - - fn get_snapshot_history_mut( - &mut self, - shard_identifier: &ShardIdentifier, - ) -> Result<&mut VecDeque>> { - self.snapshot_history - .get_mut(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier)) - } - - fn get_snapshot_history( - &self, - shard_identifier: &ShardIdentifier, - ) -> Result<&VecDeque>> { - self.snapshot_history - .get(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier)) - } - - fn get_latest_snapshot_metadata( - &self, - shard_identifier: &ShardIdentifier, - ) -> Result<&StateSnapshotMetaData> { - let snapshot_history = self.get_snapshot_history(shard_identifier)?; - snapshot_history.front().ok_or(Error::EmptyRepository) - } - - fn prune_snapshot_history_by_range>( - &mut self, - shard_identifier: &ShardIdentifier, - range: R, - ) -> Result<()> { - let state_snapshots_to_remove = self - .get_snapshot_history_mut(shard_identifier)? - .drain(range) - .collect::>(); - - self.remove_snapshots(shard_identifier, state_snapshots_to_remove.as_slice()); - Ok(()) - } - - /// Remove snapshots referenced by metadata. - /// Does not stop on error, it's guaranteed to call `remove` on all elements. - /// Logs any errors that occur. - fn remove_snapshots( - &self, - shard_identifier: &ShardIdentifier, - snapshots_metadata: &[StateSnapshotMetaData], - ) { - for snapshot_metadata in snapshots_metadata { - if let Err(e) = self.file_io.remove(shard_identifier, snapshot_metadata.state_id) { - // We just log an error, don't want to return the error here, because the operation - // in general was successful, just a side-effect that failed. - error!("Failed to remove state, with id '{}': {:?}", snapshot_metadata.state_id, e); - } - } - } - - fn write_new_state( - &self, - shard_identifier: &ShardIdentifier, - state: &FileIo::StateType, - ) -> Result<(FileIo::HashType, StateId)> { - let state_id = generate_current_timestamp_state_id(); - let state_hash = self.file_io.write(shard_identifier, state_id, state)?; - Ok((state_hash, state_id)) - } - - fn initialize_shard_with_snapshot( - &mut self, - shard_identifier: &ShardIdentifier, - state: &FileIo::StateType, - ) -> Result { - let snapshot_metadata = - initialize_shard_with_snapshot(shard_identifier, self.file_io.as_ref(), state)?; - - let state_hash = snapshot_metadata.state_hash; - self.snapshot_history - .insert(*shard_identifier, VecDeque::from([snapshot_metadata])); - Ok(state_hash) - } - - fn load_state( - &self, - shard_identifier: &ShardIdentifier, - snapshot_metadata: &StateSnapshotMetaData, - ) -> Result { - self.file_io.load(shard_identifier, snapshot_metadata.state_id) - } -} - -impl VersionedStateAccess for StateSnapshotRepository -where - FileIo: StateFileIo, - ::HashType: Copy + Eq + Debug, - ::StateType: Clone, -{ - type StateType = FileIo::StateType; - type HashType = FileIo::HashType; - - fn load_latest(&self, shard_identifier: &ShardIdentifier) -> Result { - let latest_snapshot_metadata = self.get_latest_snapshot_metadata(shard_identifier)?; - self.file_io.load(shard_identifier, latest_snapshot_metadata.state_id) - } - - fn update( - &mut self, - shard_identifier: &ShardIdentifier, - state: &Self::StateType, - state_hash: Self::HashType, - ) -> Result<()> { - if !self.shard_exists(shard_identifier) { - self.initialize_shard_with_snapshot(shard_identifier, state)?; - return Ok(()) - } - - let (_state_hash, state_id) = self.write_new_state(shard_identifier, state)?; - let cache_size = self.snapshot_history_cache_size; - - let snapshot_history = self.get_snapshot_history_mut(shard_identifier)?; - snapshot_history.push_front(StateSnapshotMetaData::new(state_hash, state_id)); - - // In case we're above max queue size we remove the oldest entries and corresponding files - if snapshot_history.len() > cache_size { - self.prune_snapshot_history_by_range(shard_identifier, cache_size..)?; - } - - Ok(()) - } - - fn revert_to( - &mut self, - shard_identifier: &ShardIdentifier, - state_hash: &Self::HashType, - ) -> Result { - let snapshot_history = self.get_snapshot_history(shard_identifier)?; - - // We use `position()` instead of `find()`, because it then allows us to easily drain - // all the newer states. - let snapshot_metadata_index = snapshot_history - .iter() - .position(|fmd| fmd.state_hash == *state_hash) - .ok_or_else(|| Error::StateNotFoundInRepository(format!("{:?}", state_hash)))?; - - // Should never fail, since we got the index from above, with `position()`. - let snapshot_metadata = snapshot_history - .get(snapshot_metadata_index) - .ok_or_else(|| Error::StateNotFoundInRepository(format!("{:?}", state_hash)))?; - - let state = self.load_state(shard_identifier, snapshot_metadata)?; - - // Remove any state versions newer than the one we're resetting to - // (do this irreversible operation last, to ensure the loading has succeeded) - self.prune_snapshot_history_by_range(shard_identifier, ..snapshot_metadata_index)?; - - Ok(state) - } - - fn initialize_new_shard( - &mut self, - shard_identifier: ShardIdentifier, - state: &Self::StateType, - ) -> Result { - self.initialize_shard_with_snapshot(&shard_identifier, state) - } - - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool { - self.snapshot_history.get(shard_identifier).is_some() - } - - fn list_shards(&self) -> Result> { - Ok(self.snapshot_history.keys().cloned().collect()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - in_memory_state_file_io::InMemoryStateFileIo, - state_snapshot_repository_loader::StateSnapshotRepositoryLoader, - test::mocks::initialize_state_mock::InitializeStateMock, - }; - use codec::Encode; - use itp_hashing::Hash; - use sp_core::{blake2_256, H256}; - use std::vec; - - #[derive(Encode, Clone, Default, Copy, Eq, PartialEq, Debug)] - struct TestState(pub u64); - - impl Hash for TestState { - fn hash(&self) -> H256 { - blake2_256(&self.encode()).into() - } - } - - type TestFileIo = InMemoryStateFileIo; - type TestStateInitializer = InitializeStateMock; - type TestSnapshotRepository = StateSnapshotRepository; - - const TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE: usize = 3; - - #[test] - fn new_with_zero_cache_size_returns_error() { - let shards = - vec![ShardIdentifier::random(), ShardIdentifier::random(), ShardIdentifier::random()]; - let file_io = create_test_file_io(shards.as_slice()); - - assert!(TestSnapshotRepository::empty(file_io.clone(), 0usize).is_err()); - } - - #[test] - fn upon_new_all_shards_are_initialized() { - let shards = - vec![ShardIdentifier::random(), ShardIdentifier::random(), ShardIdentifier::random()]; - let (file_io, state_snapshot_repository) = create_state_snapshot_repository( - shards.as_slice(), - TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE, - ); - - assert_eq!(shards.len(), file_io.list_shards().unwrap().len()); - assert_eq!(shards.len(), state_snapshot_repository.snapshot_history.len()); - assert_eq!(shards.len(), state_snapshot_repository.list_shards().unwrap().len()); - for states_per_shard in state_snapshot_repository.snapshot_history.values() { - assert_eq!(1, states_per_shard.len()); - } - for shard in shards { - assert!(state_snapshot_repository.load_latest(&shard).is_ok()); - assert!(state_snapshot_repository.shard_exists(&shard)); - } - } - - #[test] - fn update_latest_creates_new_state_file() { - let shards = - vec![ShardIdentifier::random(), ShardIdentifier::random(), ShardIdentifier::random()]; - let (file_io, mut state_snapshot_repository) = create_state_snapshot_repository( - shards.as_slice(), - TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE, - ); - - let shard_to_update = shards.get(1).unwrap(); - assert_eq!(1, file_io.get_states_for_shard(shard_to_update).unwrap().len()); - - let new_state = TestState(1234u64); - - let _ = state_snapshot_repository - .update(shard_to_update, &new_state, Default::default()) - .unwrap(); - - let snapshot_history = - state_snapshot_repository.snapshot_history.get(shard_to_update).unwrap(); - assert_eq!(2, snapshot_history.len()); - assert_eq!(new_state, state_snapshot_repository.load_latest(shard_to_update).unwrap()); - assert_eq!(2, file_io.get_states_for_shard(shard_to_update).unwrap().len()); - } - - #[test] - fn update_latest_prunes_states_when_above_cache_size() { - let shard_id = ShardIdentifier::random(); - let (file_io, mut state_snapshot_repository) = - create_state_snapshot_repository(&[shard_id], TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE); - - let states: Vec = - [1u64, 2u64, 3u64, 4u64, 5u64, 6u64].into_iter().map(|i| TestState(i)).collect(); - assert!(states.len() > TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE); // ensures we have pruning - - states.iter().for_each(|state| { - let _ = state_snapshot_repository.update(&shard_id, state, Default::default()).unwrap(); - }); - - let snapshot_history = state_snapshot_repository.snapshot_history.get(&shard_id).unwrap(); - assert_eq!(TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE, snapshot_history.len()); - assert_eq!( - *states.last().unwrap(), - state_snapshot_repository.load_latest(&shard_id).unwrap() - ); - assert_eq!( - TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE, - file_io.get_states_for_shard(&shard_id).unwrap().len() - ); - } - - #[test] - fn update_latest_with_new_shard_creates_entry_and_does_not_modify_original_shard_entry() { - let shard_id = ShardIdentifier::random(); - let (file_io, mut state_snapshot_repository) = - create_state_snapshot_repository(&[shard_id], TEST_SNAPSHOT_REPOSITORY_CACHE_SIZE); - - assert!(state_snapshot_repository - .update(&ShardIdentifier::from_low_u64_be(1u64), &TestState(45), Default::default()) - .is_ok()); - - assert_eq!(2, state_snapshot_repository.snapshot_history.len()); - let snapshot_history = state_snapshot_repository.snapshot_history.get(&shard_id).unwrap(); - assert_eq!(1, snapshot_history.len()); - assert_eq!(TestState(0u64), state_snapshot_repository.load_latest(&shard_id).unwrap()); - assert_eq!(1, file_io.get_states_for_shard(&shard_id).unwrap().len()); - } - - #[test] - fn revert_to_removes_version_newer_than_target_hash() { - let shard_id = ShardIdentifier::random(); - let (file_io, mut state_snapshot_repository) = - create_state_snapshot_repository(&[shard_id], 6); - - let states: Vec = - [1u64, 2u64, 3u64, 4u64, 5u64].into_iter().map(|i| TestState(i)).collect(); - - let state_hashes = states - .iter() - .map(|state| { - let state_hash = state.hash(); - state_snapshot_repository.update(&shard_id, state, state_hash).unwrap(); - state_hash - }) - .collect::>(); - let revert_target_hash = state_hashes.get(1).unwrap(); - - let reverted_state = - state_snapshot_repository.revert_to(&shard_id, revert_target_hash).unwrap(); - - assert_eq!(TestState(2u64), reverted_state); - assert_eq!(3, state_snapshot_repository.snapshot_history.get(&shard_id).unwrap().len()); // because we have initialized version '0' as well - assert_eq!(TestState(2u64), state_snapshot_repository.load_latest(&shard_id).unwrap()); - assert_eq!(3, file_io.get_states_for_shard(&shard_id).unwrap().len()); - } - - #[test] - fn initializing_new_shard_works() { - let (_, mut state_snapshot_repository) = create_state_snapshot_repository(&[], 2); - - let shard_id = ShardIdentifier::random(); - - assert!(state_snapshot_repository.load_latest(&shard_id).is_err()); - assert!(state_snapshot_repository.list_shards().unwrap().is_empty()); - - let _hash = state_snapshot_repository - .initialize_new_shard(shard_id, &Default::default()) - .unwrap(); - - assert!(state_snapshot_repository.load_latest(&shard_id).is_ok()); - assert_eq!(1, state_snapshot_repository.list_shards().unwrap().len()); - } - - #[test] - fn initialize_new_state_when_shard_already_exists_returns_ok() { - let shard_id = ShardIdentifier::random(); - let (_, mut state_snapshot_repository) = create_state_snapshot_repository(&[shard_id], 2); - - let _hash = state_snapshot_repository - .initialize_new_shard(shard_id, &Default::default()) - .unwrap(); - - assert!(state_snapshot_repository.load_latest(&shard_id).is_ok()); - assert_eq!(1, state_snapshot_repository.list_shards().unwrap().len()); - } - - fn create_state_snapshot_repository( - shards: &[ShardIdentifier], - snapshot_history_size: usize, - ) -> (Arc, TestSnapshotRepository) { - let file_io = create_test_file_io(shards); - let state_initializer = Arc::new(TestStateInitializer::new(Default::default())); - let repository_loader = - StateSnapshotRepositoryLoader::new(file_io.clone(), state_initializer); - (file_io, repository_loader.load_snapshot_repository(snapshot_history_size).unwrap()) - } - - fn create_test_file_io(shards: &[ShardIdentifier]) -> Arc { - Arc::new(TestFileIo::new(shards, Box::new(|x| *x), Box::new(|x| x))) - } -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs b/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs deleted file mode 100644 index f6dee1730b..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::{Error, Result}, - state_snapshot_repository::VersionedStateAccess, -}; -use itp_types::ShardIdentifier; -use std::{ - collections::{HashMap, VecDeque}, - marker::PhantomData, - string::ToString, - vec::Vec, -}; - -#[derive(Default, Clone)] -pub struct VersionedStateAccessMock { - state_history: HashMap>, - phantom_data: PhantomData, -} - -impl VersionedStateAccessMock { - #[cfg(test)] - pub fn new(state_history: HashMap>) -> Self { - VersionedStateAccessMock { state_history, phantom_data: Default::default() } - } -} - -impl VersionedStateAccess for VersionedStateAccessMock -where - State: Default + Clone, - Hash: Default, -{ - type StateType = State; - type HashType = Hash; - - fn load_latest(&self, shard_identifier: &ShardIdentifier) -> Result { - self.state_history - .get(shard_identifier) - .ok_or(Error::InvalidShard(*shard_identifier))? - .front() - .cloned() - .ok_or(Error::StateNotFoundInRepository("".to_string())) - } - - fn update( - &mut self, - shard_identifier: &ShardIdentifier, - state: &Self::StateType, - _state_hash: Self::HashType, - ) -> Result<()> { - let state_history = self - .state_history - .entry(*shard_identifier) - .or_insert_with(|| VecDeque::default()); - state_history.push_front(state.clone()); - Ok(()) - } - - fn revert_to( - &mut self, - shard_identifier: &ShardIdentifier, - _state_hash: &Self::HashType, - ) -> Result { - let state_history = self - .state_history - .get_mut(shard_identifier) - .ok_or_else(|| Error::InvalidShard(*shard_identifier))?; - state_history.drain(..).last().ok_or(Error::EmptyRepository) - } - - fn initialize_new_shard( - &mut self, - shard_identifier: ShardIdentifier, - state: &Self::StateType, - ) -> Result { - self.state_history.insert(shard_identifier, VecDeque::from([state.clone()])); - Ok(Hash::default()) - } - - fn shard_exists(&self, shard_identifier: &ShardIdentifier) -> bool { - self.state_history.get(shard_identifier).is_some() - } - - fn list_shards(&self) -> Result> { - Ok(self.state_history.keys().copied().collect()) - } -} diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/Cargo.toml b/tee-worker/bitacross/core-primitives/stf-state-observer/Cargo.toml deleted file mode 100644 index 00729ff11b..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-observer/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "itp-stf-state-observer" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local deps -itp-types = { default-features = false, path = "../types" } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -log = { version = "0.4", default-features = false } -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "itp-types/std", - "log/std", - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] -mocks = [] diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/src/state_observer.rs b/tee-worker/bitacross/core-primitives/stf-state-observer/src/state_observer.rs deleted file mode 100644 index 4e75fad729..0000000000 --- a/tee-worker/bitacross/core-primitives/stf-state-observer/src/state_observer.rs +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - traits::{ObserveState, UpdateState}, -}; -use itp_types::ShardIdentifier; -use std::{collections::HashMap, vec::Vec}; - -/// State observer implementation. Receives updates in a dedicated queue. -/// These updates are applied every time an observation function is executed. -/// -#[derive(Default)] -pub struct StateObserver { - queued_state_updates: RwLock>, - current_state: RwLock>, -} - -impl StateObserver { - pub fn new(shard: ShardIdentifier, state: StateType) -> Self { - Self { - queued_state_updates: Default::default(), - current_state: RwLock::new(HashMap::from([(shard, state)])), - } - } - - pub fn from_map(states_map: HashMap) -> Self { - Self { queued_state_updates: Default::default(), current_state: RwLock::new(states_map) } - } - - fn apply_pending_update(&self) -> Result<()> { - let mut update_queue_lock = - self.queued_state_updates.write().map_err(|_| Error::LockPoisoning)?; - - let state_updates: Vec<_> = update_queue_lock.drain().collect(); - drop(update_queue_lock); - - if !state_updates.is_empty() { - let mut current_state_lock = - self.current_state.write().map_err(|_| Error::LockPoisoning)?; - for state_update in state_updates.into_iter() { - current_state_lock.insert(state_update.0, state_update.1); - } - drop(current_state_lock); - } - - Ok(()) - } -} - -impl ObserveState for StateObserver { - type StateType = StateType; - - fn observe_state(&self, shard: &ShardIdentifier, observation_func: F) -> Result - where - F: FnOnce(&mut Self::StateType) -> R, - { - // Check if there is a pending update and apply it. - self.apply_pending_update()?; - - // Execute the observation function. - let mut current_state_map_lock = - self.current_state.write().map_err(|_| Error::LockPoisoning)?; - - match current_state_map_lock.get_mut(shard) { - Some(s) => Ok(observation_func(s)), - None => Err(Error::CurrentShardStateEmpty), - } - } -} - -impl UpdateState for StateObserver { - fn queue_state_update(&self, shard: ShardIdentifier, state: StateType) -> Result<()> { - let mut update_queue_lock = - self.queued_state_updates.write().map_err(|_| Error::LockPoisoning)?; - update_queue_lock.insert(shard, state); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use core::assert_matches::assert_matches; - - type TestState = u64; - - #[test] - fn default_constructs_empty_state() { - let state_observer = StateObserver::::default(); - - assert_matches!( - state_observer.observe_state(&shard(), |_| { () }), - Err(Error::CurrentShardStateEmpty) - ); - } - - #[test] - fn initializing_state_with_some_works() { - let state_observer = StateObserver::::new(shard(), 31u64); - assert_eq!(state_observer.observe_state(&shard(), |s| *s).unwrap(), 31u64); - } - - #[test] - fn observing_multiple_times_after_update_works() { - let state_observer = StateObserver::::default(); - - state_observer.queue_state_update(shard(), 42u64).unwrap(); - - assert_eq!(state_observer.observe_state(&shard(), |s| *s).unwrap(), 42u64); - assert_eq!(state_observer.observe_state(&shard(), |s| *s).unwrap(), 42u64); - assert_eq!(state_observer.observe_state(&shard(), |s| *s).unwrap(), 42u64); - } - - #[test] - fn updating_multiple_times_before_observation_just_keeps_last_value() { - let state_observer = StateObserver::::new(shard(), 31); - state_observer.queue_state_update(shard(), 42u64).unwrap(); - state_observer.queue_state_update(shard(), 57u64).unwrap(); - assert_eq!(1, state_observer.queued_state_updates.read().unwrap().len()); - assert_eq!(state_observer.observe_state(&shard(), |s| *s).unwrap(), 57u64); - } - - fn shard() -> ShardIdentifier { - ShardIdentifier::default() - } -} diff --git a/tee-worker/bitacross/core-primitives/storage/Cargo.toml b/tee-worker/bitacross/core-primitives/storage/Cargo.toml deleted file mode 100644 index 544f9731f6..0000000000 --- a/tee-worker/bitacross/core-primitives/storage/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "itp-storage" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["chain-error"] } -derive_more = { version = "0.99.5" } -frame-metadata = { version = "15.1.0", features = ["v14"], default-features = false } -hash-db = { version = "0.15.2", default-features = false } -thiserror = { version = "1.0.26", optional = true } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# substrate deps -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-trie = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# integritee -itp-types = { default-features = false, path = "../types" } - -[dev-dependencies] -sp-state-machine = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-metadata/std", - "frame-support/std", - "hash-db/std", - "itp-types/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "sp-trie/std", - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror-sgx", -] -test = [] diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/Cargo.toml b/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/Cargo.toml deleted file mode 100644 index c413e88a7a..0000000000 --- a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "itp-sgx-externalities" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG and Parity Technologies '] -edition = "2021" - -[dependencies] -# no_std -codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false, features = ["derive", "chain-error"] } -derive_more = "0.99.16" -log = { version = "0.4", default-features = false } -postcard = { version = "0.7.2", default-features = false, features = ["alloc"] } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -# sgx dependencies -sgx_tstd = { optional = true, features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } - -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local -environmental = { default-features = false, path = "../environmental" } -itp-hashing = { default-features = false, path = "../../hashing" } - -[dev-dependencies] -itp-storage = { default-features = false, path = "../../storage" } - -[features] -default = ["std"] -std = [ - "codec/std", - "environmental/std", - "itp-hashing/std", - "log/std", - "postcard/use-std", - "serde/std", - "itp-storage/std", - # substrate - "sp-core/std", -] -sgx = [ - "sgx_tstd", - "environmental/sgx", -] diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/src/lib.rs b/tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/src/lib.rs deleted file mode 100644 index 57f655e85e..0000000000 --- a/tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/src/lib.rs +++ /dev/null @@ -1,1012 +0,0 @@ -// Copyright 2017-2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate 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. - -// Substrate 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 Substrate. If not, see . - -//#![warn(missing_docs)] - -// Added by Integritee. Prevents warnings during compilation with sgx features at all those -// unimplemented method stubs. -#![allow(unused_variables)] -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(lang_items))] -#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))] -#![cfg_attr(not(feature = "std"), feature(core_intrinsics))] -#![cfg_attr( - feature = "std", - doc = "Substrate sgx-runtime standard library as compiled when linked with Rust's standard library." -)] -#![cfg_attr( - not(feature = "std"), - doc = "Substrate's sgx-runtime standard library as compiled without Rust's standard library." -)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(feature = "sgx")] -extern crate sgx_tstd as std; - -use codec::{Decode, Encode}; -use log::*; -use sp_core::{ - crypto::{KeyTypeId, Pair}, - ecdsa, ed25519, - hash::H256, - offchain::{ - HttpError, HttpRequestId, HttpRequestStatus, OpaqueNetworkState, StorageKind, Timestamp, - }, - sr25519, - storage::StateVersion, -}; -use std::{char, prelude::v1::String, println, vec, vec::Vec}; - -#[allow(unused)] -fn encode_hex_digit(digit: u8) -> char { - match char::from_digit(u32::from(digit), 16) { - Some(c) => c, - _ => panic!(), - } -} - -#[allow(unused)] -fn encode_hex_byte(byte: u8) -> [char; 2] { - [encode_hex_digit(byte >> 4), encode_hex_digit(byte & 0x0Fu8)] -} - -#[allow(unused)] -pub fn encode_hex(bytes: &[u8]) -> String { - let strs: Vec = bytes - .iter() - .map(|byte| encode_hex_byte(*byte).iter().copied().collect()) - .collect(); - strs.join("") -} - -// Reexport here, such that the worker does not need to import other crate. -// Not sure if this is a good Idea though. -pub use itp_sgx_externalities::{ - with_externalities, SgxExternalities, SgxExternalitiesTrait, SgxExternalitiesType, -}; - -pub struct MultiRemovalResults { - /// A continuation cursor which, if `Some` must be provided to the subsequent removal call. - /// If `None` then all removals are complete and no further calls are needed. - pub maybe_cursor: Option>, - /// The number of items removed from the backend database. - pub backend: u32, - /// The number of unique keys removed, taking into account both the backend and the overlay. - pub unique: u32, - /// The number of iterations (each requiring a storage seek/read) which were done. - pub loops: u32, -} - -/// Error verifying ECDSA signature -#[derive(Encode, Decode)] -pub enum EcdsaVerifyError { - /// Incorrect value of R or S - BadRS, - /// Incorrect value of V - BadV, - /// Invalid signature - BadSignature, -} - -/// The outcome of calling `storage_kill`. Returned value is the number of storage items -/// removed from the trie from making the `storage_kill` call. -#[derive(Encode, Decode)] -pub enum KillStorageResult { - /// No key remains in the child trie. - AllRemoved(u32), - /// At least one key still resides in the child trie due to the supplied limit. - SomeRemaining(u32), -} - -impl From for KillStorageResult { - fn from(r: MultiRemovalResults) -> Self { - match r { - MultiRemovalResults { maybe_cursor: None, backend, .. } => Self::AllRemoved(backend), - MultiRemovalResults { maybe_cursor: Some(..), backend, .. } => - Self::SomeRemaining(backend), - } - } -} - -pub mod storage { - use super::*; - - pub fn get(key: &[u8]) -> Option> { - debug!("storage('{}')", encode_hex(key)); - with_externalities(|ext| { - ext.get(key).map(|s| { - debug!(" returning {}", encode_hex(s)); - s.to_vec() - }) - }) - .expect("storage cannot be called outside of an Externalities-provided environment.") - } - - pub fn read(key: &[u8], value_out: &mut [u8], value_offset: u32) -> Option { - debug!( - "read_storage('{}' with offset = {:?}. value_out.len() is {})", - encode_hex(key), - value_offset, - value_out.len() - ); - with_externalities(|ext| { - ext.get(key).map(|value| { - debug!(" entire stored value: {:?}", value); - let value_offset = value_offset as usize; - let value = &value[value_offset..]; - debug!(" stored value at offset: {:?}", value); - let written = std::cmp::min(value.len(), value_out.len()); - value_out[..written].copy_from_slice(&value[..written]); - debug!(" write back {:?}, return len {}", value_out, value.len()); - // Just return u32::Max if we read more than u32::Max bytes. - value.len().try_into().unwrap_or(u32::MAX) - }) - }) - .expect("read_storage cannot be called outside of an Externalities-provided environment.") - } - - pub fn set(key: &[u8], value: &[u8]) { - debug!("set_storage('{}', {:x?})", encode_hex(key), value); - with_externalities(|ext| ext.insert(key.to_vec(), value.to_vec())) - .expect("`set` cannot be called outside of an Externalities-provided environment."); - } - - pub fn clear(key: &[u8]) { - with_externalities(|ext| { - if ext.remove(key).is_none() { - debug!("Tried to clear storage that was not existing"); - } - }); - } - - pub fn exists(key: &[u8]) -> bool { - with_externalities(|ext| ext.contains_key(key)) - .expect("exists cannot be called outside of an Externalities-provided environment.") - } - - /// Clear the storage of each key-value pair where the key starts with the given `prefix`. - pub fn clear_prefix_version_1(prefix: &[u8]) { - clear_prefix(prefix, None); - } - - /// Clear the storage of each key-value pair where the key starts with the given `prefix`. - /// - /// # Limit - /// - /// Deletes all keys from the overlay and up to `limit` keys from the backend if - /// it is set to `Some`. No limit is applied when `limit` is set to `None`. - /// - /// The limit can be used to partially delete a prefix storage in case it is too large - /// to delete in one go (block). - /// - /// It returns a boolean false iff some keys are remaining in - /// the prefix after the functions returns. Also returns a `u32` with - /// the number of keys removed from the process. - /// - /// # Note - /// - /// Please note that keys that are residing in the overlay for that prefix when - /// issuing this call are all deleted without counting towards the `limit`. Only keys - /// written during the current block are part of the overlay. Deleting with a `limit` - /// mostly makes sense with an empty overlay for that prefix. - /// - /// Calling this function multiple times per block for the same `prefix` does - /// not make much sense because it is not cumulative when called inside the same block. - /// Use this function to distribute the deletion of a single child trie across multiple - /// blocks. - pub fn clear_prefix(prefix: &[u8], maybe_limit: Option) -> KillStorageResult { - let number_of_removed_values = - with_externalities(|ext| ext.clear_prefix(prefix, maybe_limit)).unwrap_or_default(); - KillStorageResult::AllRemoved(number_of_removed_values) - } - - /// Append the encoded `value` to the storage item at `key`. - /// - /// The storage item needs to implement [`EncodeAppend`](codec::EncodeAppend). - /// - /// # Warning - /// - /// If the storage item does not support [`EncodeAppend`](codec::EncodeAppend) or - /// something else fails at appending, the storage item will be set to `[value]`. - pub fn append(key: &[u8], value: Vec) { - with_externalities(|ext| ext.append(key.to_vec(), value.to_vec())); - } - - /// "Commit" all existing operations and compute the resulting storage root. - /// - /// The hashing algorithm is defined by the `Block`. - /// - /// Returns a `Vec` that holds the SCALE encoded hash. - pub fn root_version_1() -> [u8; 32] { - warn!("storage::root() unimplemented"); - [0u8; 32] - } - - /// "Commit" all existing operations and compute the resulting storage root. - /// - /// The hashing algorithm is defined by the `Block`. - /// - /// Returns a `Vec` that holds the SCALE encoded hash. - pub fn root(version: StateVersion) -> [u8; 32] { - warn!("storage::root() unimplemented"); - [0u8; 32] - } - - pub fn changes_root(parent_hash: &[u8]) -> Option<[u8; 32]> { - warn!("storage::changes_root() unimplemented"); - Some([0u8; 32]) - } - - /// Get the next key in storage after the given one in lexicographic order. - pub fn next_key(key: &[u8]) -> Option> { - debug!("next_key('{}')", encode_hex(key)); - with_externalities(|ext| ext.next_storage_key(key)) - .expect("`next_key` cannot be called outside of an Externalities-provided environment.") - } - - /// Start a new nested transaction. - /// - /// This allows to either commit or roll back all changes that are made after this call. - /// For every transaction there must be a matching call to either `rollback_transaction` - /// or `commit_transaction`. This is also effective for all values manipulated using the - /// `DefaultChildStorage` API. - /// - /// # Warning - /// - /// This is a low level API that is potentially dangerous as it can easily result - /// in unbalanced transactions. For example, FRAME users should use high level storage - /// abstractions. - pub fn start_transaction() { - debug!("storage::start_transaction unimplemented"); - } - - /// Rollback the last transaction started by `start_transaction`. - /// - /// Any changes made during that transaction are discarded. - /// - /// # Panics - /// - /// Will panic if there is no open transaction. - pub fn rollback_transaction() { - debug!("storage::rollback_transaction unimplemented"); - } - - /// Commit the last transaction started by `start_transaction`. - /// - /// Any changes made during that transaction are committed. - /// - /// # Panics - /// - /// Will panic if there is no open transaction. - pub fn commit_transaction() { - debug!("storage::commit_transaction unimplemented"); - } -} - -pub mod default_child_storage { - use super::*; - - pub fn read( - storage_key: &[u8], - key: &[u8], - value_out: &mut [u8], - value_offset: u32, - ) -> Option { - // TODO unimplemented - warn!("default_child_storage::read() unimplemented"); - Some(0) - } - - pub fn get(storage_key: &[u8], key: &[u8]) -> Option> { - // TODO: unimplemented - warn!("default_child_storage::get() unimplemented"); - Some(vec![0, 1, 2, 3]) - } - - pub fn set(storage_key: &[u8], key: &[u8], value: &[u8]) { - warn!("default_child_storage::set() unimplemented"); - } - - pub fn clear(storage_key: &[u8], key: &[u8]) { - warn!("child storage::clear() unimplemented"); - } - - pub fn storage_kill_version_1(storage_key: &[u8]) { - warn!("child storage::storage_kill() unimplemented"); - } - - pub fn storage_kill_version_2(storage_key: &[u8], limit: Option) -> bool { - warn!("child storage::storage_kill() unimplemented"); - false - } - - /// Clear a child storage key. - /// - /// See `Storage` module `clear_prefix` documentation for `limit` usage. - pub fn storage_kill(storage_key: &[u8], limit: Option) -> KillStorageResult { - warn!("child storage::storage_kill() unimplemented"); - KillStorageResult::AllRemoved(0) - } - - pub fn exists(storage_key: &[u8], key: &[u8]) -> bool { - warn!("child storage::exists() unimplemented"); - false - } - - /// Clear child default key by prefix. - /// - /// Clear the child storage of each key-value pair where the key starts with the given `prefix`. - pub fn clear_prefix_version_1(storage_key: &[u8], prefix: &[u8]) { - warn!("child storage::clear_prefix() unimplemented"); - } - - /// Clear the child storage of each key-value pair where the key starts with the given `prefix`. - /// - /// See `Storage` module `clear_prefix` documentation for `limit` usage. - pub fn clear_prefix( - storage_key: &[u8], - prefix: &[u8], - limit: Option, - ) -> KillStorageResult { - warn!("child storage::clear_prefix() unimplemented"); - KillStorageResult::AllRemoved(0) - } - - pub fn root_version_1(storage_key: &[u8]) -> Vec { - warn!("child storage::root() unimplemented"); - vec![0, 1, 2, 3] - } - - pub fn root(storage_key: &[u8], version: StateVersion) -> Vec { - warn!("child storage::root() unimplemented"); - vec![0, 1, 2, 3] - } - - pub fn next_key(storage_key: &[u8], key: &[u8]) -> Option> { - warn!("child storage::next_key() unimplemented"); - Some(Vec::new()) - } -} - -pub mod trie { - use super::*; - - /// A trie root formed from the iterated items. - pub fn blake2_256_root_version_1(input: Vec<(Vec, Vec)>) -> H256 { - warn!("trie::blake2_256_root() unimplemented"); - H256::default() - } - - /// A trie root formed from the iterated items. - pub fn blake2_256_root(input: Vec<(Vec, Vec)>, version: StateVersion) -> H256 { - warn!("trie::blake2_256_root() unimplemented"); - H256::default() - } - - /// A trie root formed from the enumerated items. - pub fn blake2_256_ordered_root_version_1(input: Vec>) -> H256 { - warn!("trie::blake2_256_ordered_root() unimplemented"); - H256::default() - } - - /// A trie root formed from the enumerated items. - pub fn blake2_256_ordered_root(input: Vec>, version: StateVersion) -> H256 { - warn!("trie::blake2_256_ordered_root() unimplemented"); - H256::default() - } - - pub fn keccak_256_root_version_1(input: Vec<(Vec, Vec)>) -> H256 { - warn!("trie::keccak_256_root_version_1() unimplemented"); - H256::default() - } - - pub fn keccak_256_root(input: Vec<(Vec, Vec)>, version: StateVersion) -> H256 { - warn!("trie::keccak_256_root() unimplemented"); - H256::default() - } - - /// A trie root formed from the enumerated items. - pub fn keccak_256_ordered_root_version_1(input: Vec>) -> H256 { - warn!("trie::keccak_256_ordered_root() unimplemented"); - H256::default() - } - - /// A trie root formed from the enumerated items. - pub fn keccak_256_ordered_root(input: Vec>, version: StateVersion) -> H256 { - warn!("trie::keccak_256_ordered_root() unimplemented"); - H256::default() - } - - /// Verify trie proof - #[allow(unused)] - fn blake2_256_verify_proof_version_1( - root: H256, - proof: &[Vec], - key: &[u8], - value: &[u8], - ) -> bool { - warn!("trie::blake2_256_verify_proof() unimplemented"); - false - } - - /// Verify trie proof - #[allow(unused)] - fn blake2_256_verify_proof( - root: H256, - proof: &[Vec], - key: &[u8], - value: &[u8], - version: StateVersion, - ) -> bool { - warn!("trie::blake2_256_verify_proof() unimplemented"); - false - } - - /// Verify trie proof - #[allow(unused)] - fn keccak_256_verify_proof_version_1( - root: H256, - proof: &[Vec], - key: &[u8], - value: &[u8], - ) -> bool { - warn!("trie::keccak_256_verify_proof() unimplemented"); - false - } - - /// Verify trie proof - #[allow(unused)] - fn keccak_256_verify_proof( - root: H256, - proof: &[Vec], - key: &[u8], - value: &[u8], - version: StateVersion, - ) -> bool { - warn!("trie::keccak_256_verify_proof() unimplemented"); - false - } -} - -pub mod misc { - use super::*; - /// Print a number. - pub fn print_num(val: u64) { - debug!(target: "sgx-runtime", "{}", val); - } - - /// Print any valid `utf8` buffer. - pub fn print_utf8(utf8: &[u8]) { - if let Ok(data) = std::str::from_utf8(utf8) { - debug!(target: "sgx-runtime", "{}", data) - } - } - - /// Print any `u8` slice as hex. - pub fn print_hex(data: &[u8]) { - debug!(target: "sgx-runtime", "{:?}", data); - } - - pub fn runtime_version(wasm: &[u8]) -> Option> { - warn!("misc::runtime_version unimplemented!"); - Some([2u8; 32].to_vec()) - } -} - -/// Interfaces for working with crypto related types from within the sgx-runtime. -pub mod crypto { - use super::*; - use sp_core::H512; - pub fn ed25519_public_keys(id: KeyTypeId) -> Vec { - warn!("crypto::ed25519_public_keys unimplemented"); - vec![ed25519::Public::from_h256(H256::default())] - } - - pub fn ed25519_generate(id: KeyTypeId, seed: Option>) -> ed25519::Public { - warn!("crypto::ed25519_generate unimplemented"); - ed25519::Public::from_h256(H256::default()) - } - - pub fn ed25519_sign( - id: KeyTypeId, - pub_key: &ed25519::Public, - msg: &[u8], - ) -> Option { - warn!("crypto::ed25519_sign unimplemented"); - - Some(ed25519::Signature::from_raw(H512::default().into())) - } - - pub fn ed25519_verify(sig: &ed25519::Signature, msg: &[u8], pub_key: &ed25519::Public) -> bool { - ed25519::Pair::verify(sig, msg, pub_key) - } - - pub fn ed25519_batch_verify( - sig: &ed25519::Signature, - msg: &[u8], - pub_key: &ed25519::Public, - ) -> bool { - warn!("crypto::ed25519_batch_verify unimplemented"); - false - } - - /// Register a `sr25519` signature for batch verification. - /// - /// Batch verification must be enabled by calling [`start_batch_verify`]. - /// If batch verification is not enabled, the signature will be verified immediatley. - /// To get the result of the batch verification, [`finish_batch_verify`] - /// needs to be called. - /// - /// Returns `true` when the verification is either successful or batched. - pub fn sr25519_batch_verify( - sig: &sr25519::Signature, - msg: &[u8], - pub_key: &sr25519::Public, - ) -> bool { - warn!("crypto::sr25519_batch_verify unimplemented"); - false - } - /// Start verification extension. - pub fn start_batch_verify() { - warn!("crypto::start_batch_verify unimplemented"); - } - - pub fn finish_batch_verify() -> bool { - warn!("crypto::finish_batch_verify unimplemented"); - true - } - - pub fn sr25519_public_keys(id: KeyTypeId) -> Vec { - warn!("crypto::sr25519_public_key unimplemented"); - vec![sr25519::Public::from_h256(H256::default())] - } - - pub fn sr25519_generate(id: KeyTypeId, seed: Option>) -> sr25519::Public { - warn!("crypto::sr25519_generate unimplemented"); - sr25519::Public::from_h256(H256::default()) - } - - pub fn sr25519_sign( - id: KeyTypeId, - pubkey: &sr25519::Public, - msg: &[u8], - ) -> Option { - warn!("crypto::sr25519_sign unimplemented"); - Some(sr25519::Signature::from_raw(H512::default().into())) - } - - /// Verify `sr25519` signature. - /// - /// Returns `true` when the verification was successful. - pub fn sr25519_verify(sig: &sr25519::Signature, msg: &[u8], pub_key: &sr25519::Public) -> bool { - sr25519::Pair::verify(sig, msg, pub_key) - } - - /// Returns all `ecdsa` public keys for the given key id from the keystore. - pub fn ecdsa_public_keys(id: KeyTypeId) -> Vec { - warn!("crypto::ecdsa_public_keys unimplemented"); - Vec::new() - } - - /// Generate an `ecdsa` key for the given key type using an optional `seed` and - /// store it in the keystore. - /// - /// The `seed` needs to be a valid utf8. - /// - /// Returns the public key. - pub fn ecdsa_generate(id: KeyTypeId, seed: Option>) -> ecdsa::Public { - warn!("crypto::ecdsa_generate unimplemented"); - let raw: [u8; 33] = [0; 33]; - ecdsa::Public::from_raw(raw) - } - - /// Sign the given `msg` with the `ecdsa` key that corresponds to the given public key and - /// key type in the keystore. - /// - /// Returns the signature. - pub fn ecdsa_sign( - id: KeyTypeId, - pub_key: &ecdsa::Public, - msg: &[u8], - ) -> Option { - warn!("crypto::ecdsa_sign unimplemented"); - None - } - - /// Verify `ecdsa` signature. - /// - /// Returns `true` when the verification was successful. - pub fn ecdsa_verify(sig: &ecdsa::Signature, msg: &[u8], pub_key: &ecdsa::Public) -> bool { - ecdsa::Pair::verify(sig, msg, pub_key) - } - - /// Register a `ecdsa` signature for batch verification. - /// - /// Batch verification must be enabled by calling [`start_batch_verify`]. - /// If batch verification is not enabled, the signature will be verified immediatley. - /// To get the result of the batch verification, [`finish_batch_verify`] - /// needs to be called. - /// - /// Returns `true` when the verification is either successful or batched. - pub fn ecdsa_batch_verify(sig: &ecdsa::Signature, msg: &[u8], pub_key: &ecdsa::Public) -> bool { - warn!("crypto::ecdsa_batch_verify unimplemented"); - false - } - - pub fn secp256k1_ecdsa_recover( - sig: &[u8; 65], - msg: &[u8; 32], - ) -> Result<[u8; 64], EcdsaVerifyError> { - let rs = libsecp256k1::Signature::parse_standard_slice(&sig[0..64]) - .map_err(|_| EcdsaVerifyError::BadRS)?; - let v = libsecp256k1::RecoveryId::parse(if sig[64] > 26 { sig[64] - 27 } else { sig[64] }) - .map_err(|_| EcdsaVerifyError::BadV)?; - let pubkey = libsecp256k1::recover(&libsecp256k1::Message::parse(msg), &rs, &v) - .map_err(|_| EcdsaVerifyError::BadSignature)?; - let mut res = [0u8; 64]; - res.copy_from_slice(&pubkey.serialize()[1..65]); - - Ok(res) - } - - pub fn secp256k1_ecdsa_recover_compressed( - sig: &[u8; 65], - msg: &[u8; 32], - ) -> Result<[u8; 33], EcdsaVerifyError> { - let rs = libsecp256k1::Signature::parse_standard_slice(&sig[0..64]) - .map_err(|_| EcdsaVerifyError::BadRS)?; - let v = libsecp256k1::RecoveryId::parse(if sig[64] > 26 { sig[64] - 27 } else { sig[64] }) - .map_err(|_| EcdsaVerifyError::BadV)?; - let pubkey = libsecp256k1::recover(&libsecp256k1::Message::parse(msg), &rs, &v) - .map_err(|_| EcdsaVerifyError::BadSignature)?; - Ok(pubkey.serialize_compressed()) - } -} - -/// Interface that provides functions for hashing with different algorithms. -pub mod hashing { - use super::*; - /// Conduct a 256-bit Keccak hash. - pub fn keccak_256(data: &[u8]) -> [u8; 32] { - debug!("keccak_256 of {}", encode_hex(data)); - let hash = sp_core::hashing::keccak_256(data); - debug!(" returning hash {}", encode_hex(&hash)); - hash - } - - /// Conduct a 512-bit Keccak hash. - pub fn keccak_512(data: &[u8]) -> [u8; 64] { - debug!("keccak_512 of {}", encode_hex(data)); - let hash = sp_core::hashing::keccak_512(data); - debug!(" returning hash {}", encode_hex(&hash)); - hash - } - - /// Conduct a 256-bit Sha2 hash. - pub fn sha2_256(data: &[u8]) -> [u8; 32] { - debug!("sha2_256 of {}", encode_hex(data)); - let hash = sp_core::hashing::sha2_256(data); - debug!(" returning hash {}", encode_hex(&hash)); - hash - } - - /// Conduct a 128-bit Blake2 hash. - pub fn blake2_128(data: &[u8]) -> [u8; 16] { - debug!("blake2_128 of {}", encode_hex(data)); - let hash = sp_core::hashing::blake2_128(data); - debug!(" returning hash {}", encode_hex(&hash)); - hash - } - - /// Conduct a 256-bit Blake2 hash. - pub fn blake2_256(data: &[u8]) -> [u8; 32] { - debug!("blake2_256 of {}", encode_hex(data)); - let hash = sp_core::hashing::blake2_256(data); - debug!(" returning hash {}", encode_hex(&hash)); - hash - } - - /// Conduct four XX hashes to give a 256-bit result. - pub fn twox_256(data: &[u8]) -> [u8; 32] { - debug!("twox_256 of {}", encode_hex(data)); - let hash = sp_core::hashing::twox_256(data); - debug!(" returning {}", encode_hex(&hash)); - hash - } - - /// Conduct two XX hashes to give a 128-bit result. - pub fn twox_128(data: &[u8]) -> [u8; 16] { - debug!("twox_128 of {}", encode_hex(data)); - let hash = sp_core::hashing::twox_128(data); - debug!(" returning {}", encode_hex(&hash)); - hash - } - - /// Conduct two XX hashes to give a 64-bit result. - pub fn twox_64(data: &[u8]) -> [u8; 8] { - debug!("twox_64 of {}", encode_hex(data)); - let hash = sp_core::hashing::twox_64(data); - debug!(" returning {}", encode_hex(&hash)); - hash - } -} - -/// Interface that provides transaction indexing API. -pub mod transaction_index { - use super::*; - /// Add transaction index. Returns indexed content hash. - #[allow(unused)] - fn index(extrinsic: u32, size: u32, context_hash: [u8; 32]) { - warn!("transaction_index::index unimplemented"); - } - - /// Conduct a 512-bit Keccak hash. - #[allow(unused)] - fn renew(extrinsic: u32, context_hash: [u8; 32]) { - warn!("transaction_index::renew unimplemented"); - } -} - -pub mod offchain_index { - use super::*; - /// Write a key value pair to the Offchain DB database in a buffered fashion. - pub fn set(key: &[u8], value: &[u8]) { - warn!("offchain_index::set unimplemented"); - } - - /// Remove a key and its associated value from the Offchain DB. - pub fn clear(key: &[u8]) { - warn!("offchain_index::clear unimplemented"); - } -} - -/// Interface that provides functions to access the offchain functionality. -/// -/// These functions are being made available to the sgx-runtime and are called by the sgx-runtime. -pub mod offchain { - use super::*; - - pub fn is_validator() -> bool { - warn!("offchain::is_validator unimplemented"); - false - } - - #[allow(clippy::result_unit_err)] - pub fn submit_transaction(data: Vec) -> Result<(), ()> { - warn!("offchain::submit_transaction unimplemented"); - Err(()) - } - - #[allow(clippy::result_unit_err)] - pub fn network_state() -> Result { - warn!("offchain::network_state unimplemented"); - Err(()) - } - - pub fn timestamp() -> offchain::Timestamp { - warn!("offchain::timestamp unimplemented"); - offchain::Timestamp::default() - } - - pub fn sleep_until(deadline: offchain::Timestamp) { - warn!("offchain::sleep_until unimplemented"); - } - - pub fn random_seed() -> [u8; 32] { - warn!("offchain::random_seed unimplemented"); - [0; 32] - } - - pub fn local_storage_set(kind: offchain::StorageKind, key: &[u8], value: &[u8]) { - warn!("offchain::local_storage_set unimplemented"); - } - pub fn local_storage_clear(kind: StorageKind, key: &[u8]) { - warn!("offchain::local_storage_clear unimplemented"); - } - - pub fn local_storage_compare_and_set( - kind: offchain::StorageKind, - key: &[u8], - old_value: Option>, - new_value: &[u8], - ) -> bool { - warn!("offchain::local_storage_compare_and_set unimplemented"); - false - } - - pub fn local_storage_get(kind: offchain::StorageKind, key: &[u8]) -> Option> { - warn!("offchain::local_storage_get unimplemented"); - None - } - - #[allow(clippy::result_unit_err)] - pub fn http_request_start( - method: &str, - uri: &str, - meta: &[u8], - ) -> Result { - warn!("offchain::http_request_start unimplemented"); - Err(()) - } - - #[allow(clippy::result_unit_err)] - pub fn http_request_add_header( - request_id: offchain::HttpRequestId, - name: &str, - value: &str, - ) -> Result<(), ()> { - warn!("offchain::http_request_add_header unimplemented"); - Err(()) - } - - pub fn http_request_write_body( - request_id: offchain::HttpRequestId, - chunk: &[u8], - deadline: Option, - ) -> Result<(), offchain::HttpError> { - warn!("offchain::http_request_write_body unimplemented"); - Err(offchain::HttpError::IoError) - } - - pub fn http_response_wait( - ids: &[offchain::HttpRequestId], - deadline: Option, - ) -> Vec { - warn!("offchain::http_response_wait unimplemented"); - Vec::new() - } - - pub fn http_response_headers(request_id: offchain::HttpRequestId) -> Vec<(Vec, Vec)> { - warn!("offchain::http_response_wait unimplemented"); - Vec::new() - } - - pub fn http_response_read_body( - request_id: offchain::HttpRequestId, - buffer: &mut [u8], - deadline: Option, - ) -> Result { - warn!("offchain::http_response_read_body unimplemented"); - Err(offchain::HttpError::IoError) - } -} - -/// Interface that provides functions for logging from within the sgx-runtime. -pub mod logging { - use super::*; - use sp_core::{LogLevel, LogLevelFilter}; - /// Request to print a log message on the host. - /// - /// Note that this will be only displayed if the host is enabled to display log messages with - /// given level and target. - /// - /// Instead of using directly, prefer setting up `RuntimeLogger` and using `log` macros. - pub fn log(level: LogLevel, target: &str, message: &[u8]) { - if let Ok(message) = std::str::from_utf8(message) { - // TODO remove this attention boost - println!("\x1b[0;36m[{}]\x1b[0m {}", target, message); - let level = match level { - LogLevel::Error => log::Level::Error, - LogLevel::Warn => log::Level::Warn, - LogLevel::Info => log::Level::Info, - LogLevel::Debug => log::Level::Debug, - LogLevel::Trace => log::Level::Trace, - }; - // FIXME: this logs with target sp_io::logging instead of the provided target! - log::log!(target: target, level, "{}", message,); - } - } - - /// Returns the max log level used by the host. - pub fn max_level() -> LogLevelFilter { - log::max_level().into() - } -} - -mod tracing_setup { - /// Initialize tracing of sp_tracing not necessary – noop. To enable build - /// without std and with the `with-tracing`-feature. - pub fn init_tracing() {} -} - -pub use tracing_setup::init_tracing; - -#[cfg(test)] -mod tests { - use super::*; - use sp_core::storage::well_known_keys::CODE; - - #[test] - fn storage_set_and_retrieve_works() { - let mut ext = SgxExternalities::default(); - - ext.execute_with(|| { - storage::set(b"doe".to_vec().as_slice(), b"reindeer".to_vec().as_slice()); - storage::set(b"dog".to_vec().as_slice(), b"puppy".to_vec().as_slice()); - storage::set(b"dogglesworth".to_vec().as_slice(), b"cat".to_vec().as_slice()); - }); - - ext.execute_with(|| { - assert!(storage::get(b"doe".to_vec().as_slice()).is_some()); - assert!(storage::get(b"dog".to_vec().as_slice()).is_some()); - assert!(storage::get(b"dogglesworth".to_vec().as_slice()).is_some()); - assert!(storage::get(b"boat".to_vec().as_slice()).is_none()); - }); - } - - #[test] - fn externalities_set_and_retrieve_code() { - let mut ext = SgxExternalities::default(); - - let code = vec![1, 2, 3]; - ext.insert(CODE.to_vec(), code.clone()); - - assert_eq!(ext.get(CODE).unwrap(), &code); - } - - #[test] - #[should_panic( - expected = "`set` cannot be called outside of an Externalities-provided environment." - )] - fn storage_set_without_externalities_panics() { - storage::set(b"hello", b"world"); - } - - #[test] - fn storage_set_and_next_key_works() { - let mut ext = SgxExternalities::default(); - - ext.execute_with(|| { - storage::set(b"doe".to_vec().as_slice(), b"reindeer".to_vec().as_slice()); - storage::set(b"dog".to_vec().as_slice(), b"puppy".to_vec().as_slice()); - storage::set(b"dogglesworth".to_vec().as_slice(), b"cat".to_vec().as_slice()); - }); - - ext.execute_with(|| { - assert_eq!(storage::next_key(&[]), Some(b"doe".to_vec())); - assert_eq!(storage::next_key(b"d".to_vec().as_slice()), Some(b"doe".to_vec())); - assert_eq!( - storage::next_key(b"dog".to_vec().as_slice()), - Some(b"dogglesworth".to_vec()) - ); - assert_eq!( - storage::next_key(b"doga".to_vec().as_slice()), - Some(b"dogglesworth".to_vec()) - ); - assert_eq!(storage::next_key(b"dogglesworth".to_vec().as_slice()), None); - assert_eq!(storage::next_key(b"e".to_vec().as_slice()), None); - }); - } - - #[test] - fn storage_next_key_in_empty_externatility_works() { - let mut ext = SgxExternalities::default(); - ext.execute_with(|| { - assert_eq!(storage::next_key(&[]), None); - assert_eq!(storage::next_key(b"dog".to_vec().as_slice()), None); - }); - } - - #[test] - #[should_panic( - expected = "`next_key` cannot be called outside of an Externalities-provided environment." - )] - fn storage_next_key_without_externalities_panics() { - storage::next_key(b"d".to_vec().as_slice()); - } -} diff --git a/tee-worker/bitacross/core-primitives/test/Cargo.toml b/tee-worker/bitacross/core-primitives/test/Cargo.toml deleted file mode 100644 index 33805a23a7..0000000000 --- a/tee-worker/bitacross/core-primitives/test/Cargo.toml +++ /dev/null @@ -1,70 +0,0 @@ -[package] -name = "itp-test" -version = "0.1.0" -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } - -# sgx deps -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate deps -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-io = { default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"], path = "../../core-primitives/substrate-sgx/sp-io" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-node-api = { path = "../node-api", default-features = false } -itp-node-api-metadata-provider = { path = "../node-api/metadata-provider", default-features = false } -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../substrate-sgx/externalities" } -itp-stf-interface = { path = "../stf-interface", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-storage = { path = "../storage", default-features = false } -itp-types = { path = "../types", default-features = false, features = ["test"] } - -# litentry -hex = { version = "0.4.3", default-features = false } -lc-teebag-storage = { path = "../../litentry/core/teebag-storage", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-node-api-metadata-provider/std", - "itp-node-api/std", - "itp-ocall-api/std", - "itp-sgx-crypto/std", - "itp-sgx-externalities/std", - "itp-stf-interface/std", - "itp-stf-primitives/std", - "itp-stf-state-handler/std", - "itp-storage/std", - "itp-types/std", - "log/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "litentry-primitives/std", - "lc-teebag-storage/std", -] -sgx = [ - "itp-node-api/sgx", - "itp-node-api-metadata-provider/sgx", - "itp-sgx-crypto/sgx", - "itp-sgx-externalities/sgx", - "itp-stf-state-handler/sgx", - "jsonrpc-core_sgx", - "sgx_tstd", - "litentry-primitives/sgx", -] diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/onchain_mock.rs b/tee-worker/bitacross/core-primitives/test/src/mock/onchain_mock.rs deleted file mode 100644 index 5871396aee..0000000000 --- a/tee-worker/bitacross/core-primitives/test/src/mock/onchain_mock.rs +++ /dev/null @@ -1,206 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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 codec::{Decode, Encode}; -use core::fmt::Debug; -use itp_ocall_api::{EnclaveAttestationOCallApi, EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; -use itp_storage::Error::StorageValueUnavailable; -use itp_types::{ - parentchain::ParentchainId, storage::StorageEntryVerified, AccountId, WorkerRequest, - WorkerResponse, WorkerType, -}; -use lc_teebag_storage::{TeebagStorage, TeebagStorageKeys}; -use sgx_types::*; -use sp_core::H256; -use sp_runtime::{traits::Header as HeaderTrait, OpaqueExtrinsic}; -use sp_std::prelude::*; -use std::collections::HashMap; - -#[derive(Default, Clone, Debug)] -pub struct OnchainMock { - inner: HashMap, Vec>, - mr_enclave: [u8; SGX_HASH_SIZE], -} - -impl OnchainMock { - pub fn with_storage_entries_at_header, V: Encode>( - mut self, - header: &Header, - entries: Vec<(Vec, V)>, - ) -> Self { - for (key, value) in entries.into_iter() { - self.insert_at_header(header, key, value.encode()); - } - self - } - - pub fn add_validateer_set>( - mut self, - header: &Header, - set: Option>, - ) -> Self { - let set: Vec = set.unwrap_or_else(validateer_set); - self.insert_at_header( - header, - TeebagStorage::enclave_identifier(WorkerType::BitAcross), - set.encode(), - ); - self - } - - pub fn with_mr_enclave(mut self, mr_enclave: [u8; SGX_HASH_SIZE]) -> Self { - self.mr_enclave = mr_enclave; - self - } - - pub fn insert_at_header>( - &mut self, - header: &Header, - key: Vec, - value: Vec, - ) { - let key_with_header = (header, key).encode(); - self.inner.insert(key_with_header, value); - } - - pub fn get_at_header>( - &self, - header: &Header, - key: &[u8], - ) -> Option<&Vec> { - let key_with_header = (header, key).encode(); - self.inner.get(&key_with_header) - } -} - -impl EnclaveAttestationOCallApi for OnchainMock { - fn sgx_init_quote(&self) -> SgxResult<(sgx_target_info_t, sgx_epid_group_id_t)> { - todo!() - } - - fn get_ias_socket(&self) -> SgxResult { - Ok(42) - } - - fn get_quote( - &self, - _sig_rl: Vec, - _report: sgx_report_t, - _sign_type: sgx_quote_sign_type_t, - _spid: sgx_spid_t, - _quote_nonce: sgx_quote_nonce_t, - ) -> SgxResult<(sgx_report_t, Vec)> { - todo!() - } - - fn get_dcap_quote(&self, _report: sgx_report_t, _quote_size: u32) -> SgxResult> { - todo!() - } - - fn get_qve_report_on_quote( - &self, - _quote: Vec, - _current_time: i64, - _quote_collateral: sgx_ql_qve_collateral_t, - _qve_report_info: sgx_ql_qe_report_info_t, - _supplemental_data_size: u32, - ) -> SgxResult<(u32, sgx_ql_qv_result_t, sgx_ql_qe_report_info_t, Vec)> { - todo!() - } - - fn get_update_info( - &self, - _platform_info: sgx_platform_info_t, - _enclave_trusted: i32, - ) -> SgxResult { - todo!() - } - - fn get_mrenclave_of_self(&self) -> SgxResult { - Ok(sgx_measurement_t { m: self.mr_enclave }) - } -} - -impl EnclaveMetricsOCallApi for OnchainMock { - fn update_metric(&self, _metric: Metric) -> SgxResult<()> { - Ok(()) - } -} - -impl EnclaveOnChainOCallApi for OnchainMock { - fn send_to_parentchain( - &self, - _extrinsics: Vec, - _: &ParentchainId, - _: bool, - ) -> SgxResult<()> { - Ok(()) - } - - fn worker_request( - &self, - _req: Vec, - _: &ParentchainId, - ) -> SgxResult>> { - Ok(Vec::new()) - } - - fn get_storage_verified, V: Decode>( - &self, - storage_hash: Vec, - header: &Header, - parentchain_id: &ParentchainId, - ) -> Result, itp_ocall_api::Error> { - self.get_multiple_storages_verified(vec![storage_hash], header, parentchain_id)? - .into_iter() - .next() - .ok_or_else(|| itp_ocall_api::Error::Storage(StorageValueUnavailable)) - } - - fn get_multiple_storages_verified, V: Decode>( - &self, - storage_hashes: Vec>, - header: &Header, - _: &ParentchainId, - ) -> Result>, itp_ocall_api::Error> { - let mut entries = Vec::with_capacity(storage_hashes.len()); - for hash in storage_hashes.into_iter() { - let value = self - .get_at_header(header, &hash) - .map(|val| Decode::decode(&mut val.as_slice())) - .transpose() - .map_err(itp_ocall_api::Error::Codec)?; - - entries.push(StorageEntryVerified::new(hash, value)) - } - Ok(entries) - } - - fn get_storage_keys(&self, _key_prefix: Vec) -> Result>, itp_ocall_api::Error> { - Ok(Default::default()) - } -} - -pub fn validateer_set() -> Vec { - vec![ - AccountId::from([0; 32]), - AccountId::from([1; 32]), - AccountId::from([2; 32]), - AccountId::from([3; 32]), - ] -} diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs b/tee-worker/bitacross/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs deleted file mode 100644 index 640a6aa73f..0000000000 --- a/tee-worker/bitacross/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use itp_ocall_api::EnclaveMetricsOCallApi; -use sgx_types::SgxResult; -use std::vec::Vec; - -pub struct SidechainOCallApiMock { - fetch_from_peer_blocks: Option>, - number_of_fetch_calls: RwLock, - _phantom: PhantomData, -} - -impl SidechainOCallApiMock -where - SignedSidechainBlockType: Clone + Encode + Decode + Send + Sync, -{ - pub fn with_peer_fetch_blocks(mut self, blocks: Vec) -> Self { - self.fetch_from_peer_blocks = Some(blocks); - self - } - - pub fn number_of_fetch_calls(&self) -> usize { - *self.number_of_fetch_calls.read().unwrap() - } -} - -impl Default for SidechainOCallApiMock { - fn default() -> Self { - SidechainOCallApiMock { - fetch_from_peer_blocks: None, - number_of_fetch_calls: RwLock::new(0), - _phantom: Default::default(), - } - } -} - -impl Clone for SidechainOCallApiMock -where - SignedSidechainBlockType: Clone + Encode + Decode + Send + Sync, -{ - fn clone(&self) -> Self { - SidechainOCallApiMock { - fetch_from_peer_blocks: self.fetch_from_peer_blocks.clone(), - number_of_fetch_calls: RwLock::new(*self.number_of_fetch_calls.read().unwrap()), - _phantom: self._phantom, - } - } -} - -impl EnclaveMetricsOCallApi - for SidechainOCallApiMock -where - SignedSidechainBlockType: Clone + Encode + Decode + Send + Sync, -{ - fn update_metric(&self, _metric: Metric) -> SgxResult<()> { - Ok(()) - } -} diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/stf_mock.rs b/tee-worker/bitacross/core-primitives/test/src/mock/stf_mock.rs deleted file mode 100644 index d5e9ec9b72..0000000000 --- a/tee-worker/bitacross/core-primitives/test/src/mock/stf_mock.rs +++ /dev/null @@ -1,297 +0,0 @@ -/* - Copyright 2021 Integritee AG - - Licensed 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 alloc::{boxed::Box, sync::Arc}; -use codec::{Decode, Encode}; -use core::fmt::Debug; -use itp_node_api::metadata::metadata_mocks::NodeMetadataMock; -use itp_node_api_metadata_provider::NodeMetadataRepository; -use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesDiffType, SgxExternalitiesTrait}; -use itp_stf_interface::{ - runtime_upgrade::RuntimeUpgradeInterface, ExecuteCall, InitState, StateCallInterface, - StateGetterInterface, UpdateState, -}; -use itp_stf_primitives::{ - traits::{ - GetterAuthorization, PoolTransactionValidation, TrustedCallSigning, TrustedCallVerification, - }, - types::{KeyPair, Nonce, TrustedOperation}, -}; -use itp_types::{ - parentchain::{ParentchainCall, ParentchainId}, - AccountId, Balance, Index, ShardIdentifier, H256, -}; -use litentry_primitives::{Identity, LitentryMultiSignature}; -use log::*; -use sp_core::{sr25519, Pair}; -use sp_runtime::transaction_validity::{ - TransactionValidityError, UnknownTransaction, ValidTransaction, -}; -use sp_std::{vec, vec::Vec}; -use std::{thread::sleep, time::Duration}; - -// a few dummy types -type NodeMetadataRepositoryMock = NodeMetadataRepository; - -#[derive(Debug, PartialEq, Eq, Encode)] -pub enum StfMockError { - Dummy, -} -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -pub struct StfMock { - state: SgxExternalities, -} - -impl UpdateState for StfMock { - fn apply_state_diff(_state: &mut SgxExternalities, _map_update: SgxExternalitiesDiffType) {} - - fn storage_hashes_to_update_on_block(_parentchain_id: &ParentchainId) -> Vec> { - vec![] - } -} - -impl StateCallInterface - for StfMock -{ - type Error = StfMockError; - type Result = (); - - fn execute_call( - state: &mut SgxExternalities, - shard: &ShardIdentifier, - call: TrustedCallSignedMock, - top_hash: H256, - calls: &mut Vec, - node_metadata_repo: Arc, - ) -> Result<(), Self::Error> { - state.execute_with(|| call.execute(shard, top_hash, calls, node_metadata_repo)) - } -} - -impl InitState for StfMock { - fn init_state(_enclave_account: AccountId) -> SgxExternalities { - SgxExternalities::new(Default::default()) - } -} - -impl StateGetterInterface for StfMock { - fn execute_getter(_state: &mut SgxExternalities, _getter: GetterMock) -> Option> { - Some(vec![42]) - } -} - -impl RuntimeUpgradeInterface for StfMock { - type Error = StfMockError; - fn on_runtime_upgrade(_state: &mut SgxExternalities) -> Result<(), Self::Error> { - Ok(()) - } -} - -pub type TrustedOperationMock = TrustedOperation; - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum TrustedCallMock { - noop(Identity), - balance_transfer(Identity, AccountId, Balance), - waste_time_ms(Identity, u64), -} - -impl TrustedCallMock { - pub fn sender_identity(&self) -> &Identity { - match self { - Self::noop(sender_identity) => sender_identity, - Self::balance_transfer(sender_identity, ..) => sender_identity, - Self::waste_time_ms(sender_identity, ..) => sender_identity, - } - } -} - -impl TrustedCallSigning for TrustedCallMock { - fn sign( - &self, - pair: &KeyPair, - nonce: Index, - mrenclave: &[u8; 32], - shard: &ShardIdentifier, - ) -> TrustedCallSignedMock { - let mut payload = self.encode(); - payload.append(&mut nonce.encode()); - payload.append(&mut mrenclave.encode()); - payload.append(&mut shard.encode()); - - TrustedCallSignedMock { - call: self.clone(), - nonce, - signature: pair.sign(payload.as_slice()), - } - } -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -pub struct TrustedCallSignedMock { - pub call: TrustedCallMock, - pub nonce: Index, - pub signature: LitentryMultiSignature, -} - -impl TrustedCallSignedMock { - pub fn new(call: TrustedCallMock, nonce: Index, signature: LitentryMultiSignature) -> Self { - TrustedCallSignedMock { call, nonce, signature } - } - - pub fn into_trusted_operation( - self, - direct: bool, - ) -> TrustedOperation { - match direct { - true => TrustedOperation::direct_call(self), - false => TrustedOperation::indirect_call(self), - } - } -} - -impl Default for TrustedCallSignedMock { - fn default() -> Self { - mock_trusted_call_signed(0) - } -} - -impl ExecuteCall for TrustedCallSignedMock { - type Error = StfMockError; - type Result = (); - - fn execute( - self, - _shard: &ShardIdentifier, - _top_hash: H256, - _calls: &mut Vec, - _node_metadata_repo: Arc, - ) -> Result<(), Self::Error> { - match self.call { - TrustedCallMock::noop(_) => Ok(()), - TrustedCallMock::balance_transfer(_, _, balance) => { - info!("touching state"); - sp_io::storage::set(b"dummy_key", &balance.encode()); - Ok(()) - }, - TrustedCallMock::waste_time_ms(_, ms) => { - sp_io::storage::set(b"dummy_key_waste_time", &42u8.encode()); - info!("executing stf call waste_time_ms. sleeping for {}ms", ms); - sleep(Duration::from_millis(ms)); - Ok(()) - }, - } - } - - fn get_storage_hashes_to_update(self) -> Vec> { - Vec::new() - } -} - -impl TrustedCallVerification for TrustedCallSignedMock { - fn sender_identity(&self) -> &Identity { - self.call.sender_identity() - } - - fn nonce(&self) -> Index { - self.nonce - } - - fn verify_signature(&self, _mrenclave: &[u8; 32], _shard: &ShardIdentifier) -> bool { - true - } -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum GetterMock { - public(PublicGetterMock), - trusted(TrustedGetterSignedMock), -} - -impl Default for GetterMock { - fn default() -> Self { - GetterMock::public(PublicGetterMock::some_value) - } -} - -impl PoolTransactionValidation for GetterMock { - fn validate(&self) -> Result { - Err(TransactionValidityError::Unknown(UnknownTransaction::CannotLookup)) - } -} - -impl GetterAuthorization for GetterMock { - fn is_authorized(&self) -> bool { - match self { - Self::trusted(tgs) => tgs.signature, - Self::public(_) => true, - } - } -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum PublicGetterMock { - some_value, -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum TrustedGetterMock { - some_value, -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -pub struct TrustedGetterSignedMock { - pub getter: TrustedGetterMock, - pub signature: bool, -} - -const MOCK_SEED: [u8; 32] = *b"34567890123456789012345678901234"; - -pub fn mock_key_pair() -> KeyPair { - KeyPair::Sr25519(Box::new(sr25519::Pair::from_seed(&MOCK_SEED))) -} - -pub fn mock_trusted_call_signed(nonce: Nonce) -> TrustedCallSignedMock { - TrustedCallMock::balance_transfer( - mock_key_pair().account_id().into(), - mock_key_pair().account_id(), - 42, - ) - .sign(&mock_key_pair(), nonce, &[0u8; 32], &ShardIdentifier::default()) -} - -pub fn mock_top_direct_trusted_call_signed() -> TrustedOperationMock { - TrustedOperationMock::direct_call(mock_trusted_call_signed(0)) -} - -pub fn mock_top_indirect_trusted_call_signed() -> TrustedOperationMock { - TrustedOperationMock::indirect_call(mock_trusted_call_signed(0)) -} - -pub fn mock_top_trusted_getter_signed() -> TrustedOperationMock { - TrustedOperationMock::get(GetterMock::trusted(TrustedGetterSignedMock { - getter: TrustedGetterMock::some_value, - signature: true, - })) -} - -pub fn mock_top_public_getter() -> TrustedOperationMock { - TrustedOperationMock::get(GetterMock::public(PublicGetterMock::some_value)) -} diff --git a/tee-worker/bitacross/core-primitives/time-utils/Cargo.toml b/tee-worker/bitacross/core-primitives/time-utils/Cargo.toml deleted file mode 100644 index cf8a8d2285..0000000000 --- a/tee-worker/bitacross/core-primitives/time-utils/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "itp-time-utils" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -chrono = { version = "0.4.19", features = ["alloc"], optional = true } - -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - "chrono", -] -sgx = [ - "sgx_tstd", - "chrono_sgx", -] diff --git a/tee-worker/bitacross/core-primitives/top-pool-author/Cargo.toml b/tee-worker/bitacross/core-primitives/top-pool-author/Cargo.toml index 86c52d54be..dbfa28d14f 100644 --- a/tee-worker/bitacross/core-primitives/top-pool-author/Cargo.toml +++ b/tee-worker/bitacross/core-primitives/top-pool-author/Cargo.toml @@ -1,62 +1,68 @@ [package] -name = "itp-top-pool-author" +name = "bc-itp-top-pool-author" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, optional = true } -# local dependencies -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-test = { path = "../test", default-features = false, optional = true } -itp-top-pool = { path = "../top-pool", default-features = false } -itp-types = { path = "../types", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-test = { workspace = true, optional = true } +itp-top-pool = { package = "bc-itp-top-pool", path = "../top-pool", default-features = false } +itp-types = { workspace = true } +itp-utils = { workspace = true } +litentry-primitives = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } +jsonrpc-core = { workspace = true, optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +lazy_static = { workspace = true, optional = true } +log = { workspace = true } -# no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -lazy_static = { version = "1.1.0", optional = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } [dev-dependencies] -futures = { version = "0.3" } -itp-sgx-crypto = { path = "../sgx/crypto", features = ["mocks"] } -itp-test = { path = "../test" } -itp-top-pool = { path = "../top-pool", features = ["mocks"] } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - +futures = { workspace = true } +itp-sgx-crypto = { workspace = true, features = ["mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool = { package = "bc-itp-top-pool", path = "../top-pool", features = ["std", "mocks"] } +sgx_crypto_helper = { workspace = true } +sp-keyring = { workspace = true } [features] default = ["std"] std = [ "itp-sgx-crypto/std", + "itp-enclave-metrics/std", + "itp-ocall-api/std", "itp-stf-state-handler/std", "itp-top-pool/std", "itp-types/std", "jsonrpc-core", "log/std", + "litentry-primitives/std", + "itp-utils/std", + "sgx_crypto_helper/default", ] sgx = [ "sgx_tstd", "jsonrpc-core_sgx", + "itp-enclave-metrics/sgx", "itp-sgx-crypto/sgx", "itp-stf-state-handler/sgx", "itp-top-pool/sgx", + "litentry-primitives/sgx", + "sgx_crypto_helper/mesalock_sgx", ] test = ["itp-test/sgx", "itp-top-pool/mocks"] mocks = ["lazy_static"] +sidechain = [] offchain-worker = [] diff --git a/tee-worker/bitacross/core-primitives/top-pool/Cargo.toml b/tee-worker/bitacross/core-primitives/top-pool/Cargo.toml index 93ab1e9764..fda8d7cc4f 100644 --- a/tee-worker/bitacross/core-primitives/top-pool/Cargo.toml +++ b/tee-worker/bitacross/core-primitives/top-pool/Cargo.toml @@ -1,42 +1,35 @@ [package] -name = "itp-top-pool" +name = "bc-itp-top-pool" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread", "untrusted_time"] } +sgx_tstd = { workspace = true, features = ["net", "thread", "untrusted_time"], optional = true } -# local dependencies -itc-direct-rpc-server = { path = "../../core/direct-rpc-server", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-types = { path = "../types", default-features = false } +itc-direct-rpc-server = { package = "bc-itc-direct-rpc-server", path = "../../core/direct-rpc-server", default-features = false } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -linked-hash-map_sgx = { package = "linked-hash-map", git = "https://github.com/mesalock-linux/linked-hash-map-sgx", optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } +linked-hash-map_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } -linked-hash-map = { version = "0.5.2", optional = true } +jsonrpc-core = { workspace = true, optional = true } +linked-hash-map = { workspace = true, optional = true } -# no-std compatible libraries -byteorder = { version = "1.4.2", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +byteorder = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } -# dev dependencies (for tests) [dev-dependencies] -parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] } -itp-test = { path = "../test", default-features = false } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +parity-util-mem = { workspace = true, features = ["primitive-types"] } +itp-test = { workspace = true } +serde = { workspace = true } +sp-application-crypto = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] @@ -45,7 +38,6 @@ sgx = [ "itc-direct-rpc-server/sgx", "jsonrpc-core_sgx", "linked-hash-map_sgx", - # litentry "litentry-primitives/sgx", ] std = [ @@ -58,7 +50,6 @@ std = [ "sp-core/std", "sp-runtime/std", "sp-application-crypto/std", - # litentry "litentry-primitives/std", ] mocks = [] diff --git a/tee-worker/bitacross/core-primitives/types/Cargo.toml b/tee-worker/bitacross/core-primitives/types/Cargo.toml deleted file mode 100644 index ff6863e7a0..0000000000 --- a/tee-worker/bitacross/core-primitives/types/Cargo.toml +++ /dev/null @@ -1,52 +0,0 @@ -[package] -name = "itp-types" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -homepage = 'https://litentry.com/' -repository = 'https://github.com/litentry/litentry-parachain' -license = "Apache-2.0" -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -# local dependencies -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-utils = { path = "../../core-primitives/utils", default-features = false } - -# scs -substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# substrate-deps -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-sgx-crypto/std", - "itp-sgx-runtime-primitives/std", - "itp-stf-primitives/std", - "itp-utils/std", - "substrate-api-client/std", - # substrate - "frame-system/std", - "pallet-balances/std", - "serde/std", - "sp-std/std", - "sp-core/std", - "sp-runtime/std", - # litentry - "litentry-primitives/std", -] -test = [] diff --git a/tee-worker/bitacross/core-primitives/types/src/lib.rs b/tee-worker/bitacross/core-primitives/types/src/lib.rs deleted file mode 100644 index b1b74b3787..0000000000 --- a/tee-worker/bitacross/core-primitives/types/src/lib.rs +++ /dev/null @@ -1,174 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(target_env = "sgx"), not(feature = "std")), no_std)] -#![cfg_attr(target_env = "sgx", feature(rustc_private))] - -use crate::storage::StorageEntry; -use codec::{Decode, Encode}; -use itp_sgx_crypto::ShieldingCryptoDecrypt; -use litentry_primitives::decl_rsa_request; -use sp_std::{boxed::Box, fmt::Debug, vec::Vec}; - -pub mod parentchain; -pub mod storage; - -pub use itp_sgx_runtime_primitives::types::*; -pub use litentry_primitives::{ - AttestationType, DcapProvider, DecryptableRequest, Enclave, EnclaveFingerprint, MrEnclave, - WorkerType, -}; -pub use sp_core::{crypto::AccountId32 as AccountId, H256}; - -pub type IpfsHash = [u8; 46]; -pub type CallIndex = [u8; 2]; - -pub type PostOpaqueTaskFn = (CallIndex, RsaRequest); - -/// Simple blob to hold an encoded call -#[derive(Debug, PartialEq, Eq, Clone, Default)] -pub struct OpaqueCall(pub Vec); - -impl OpaqueCall { - /// Convert call tuple to an `OpaqueCall`. - pub fn from_tuple(call: &C) -> Self { - OpaqueCall(call.encode()) - } -} - -impl Encode for OpaqueCall { - fn encode(&self) -> Vec { - self.0.clone() - } -} - -// Litentry: re-declared due to orphan rule (that's why macro is used) -decl_rsa_request!(Debug); - -impl DecryptableRequest for RsaRequest { - type Error = (); - - fn shard(&self) -> ShardIdentifier { - self.shard - } - - fn payload(&self) -> &[u8] { - self.payload.as_slice() - } - - fn decrypt( - &mut self, - enclave_shielding_key: Box>, - ) -> core::result::Result, ()> { - enclave_shielding_key.decrypt(self.payload.as_slice()).map_err(|_| ()) - } -} - -#[derive(Debug, Clone, PartialEq, Encode, Decode, Eq)] -pub enum DirectRequestStatus { - /// Direct request was successfully executed - #[codec(index = 0)] - Ok, - /// Direct request could not be executed - #[codec(index = 1)] - Error, - /// Trusted Call Status - /// Litentry: embed the top hash here - TODO - use generic type? - #[codec(index = 2)] - TrustedOperationStatus(TrustedOperationStatus, H256), - - #[codec(index = 3)] - Processing(H256), -} - -#[derive(Debug, Clone, PartialEq, Encode, Decode, Eq)] -pub enum TrustedOperationStatus { - /// TrustedOperation is submitted to the top pool. - #[codec(index = 0)] - Submitted, - /// TrustedOperation is part of the future queue. - #[codec(index = 1)] - Future, - /// TrustedOperation is part of the ready queue. - #[codec(index = 2)] - Ready, - /// The operation has been broadcast to the given peers. - #[codec(index = 3)] - Broadcast, - /// TrustedOperation has been included in block with given hash. - #[codec(index = 4)] - InSidechainBlock(BlockHash), - /// The block this operation was included in has been retracted. - #[codec(index = 5)] - Retracted, - /// Maximum number of finality watchers has been reached, - /// old watchers are being removed. - #[codec(index = 6)] - FinalityTimeout, - /// TrustedOperation has been finalized by a finality-gadget, e.g GRANDPA - #[codec(index = 7)] - Finalized, - /// TrustedOperation has been replaced in the pool, by another operation - /// that provides the same tags. (e.g. same (sender, nonce)). - #[codec(index = 8)] - Usurped, - /// TrustedOperation has been dropped from the pool because of the limit. - #[codec(index = 9)] - Dropped, - /// TrustedOperation is no longer valid in the current state. - #[codec(index = 10)] - Invalid, - /// TrustedOperation has been executed. - TopExecuted(Vec, bool), -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq)] -pub enum WorkerRequest { - #[codec(index = 0)] - ChainStorage(Vec, Option), // (storage_key, at_block) - #[codec(index = 1)] - ChainStorageKeys(Vec, Option), // (storage_key_prefix, at_block) -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq)] -pub enum WorkerResponse { - #[codec(index = 0)] - ChainStorage(Vec, Option, Option>>), // (storage_key, storage_value, storage_proof) - #[codec(index = 1)] - ChainStorageKeys(Vec>), // (storage_keys) -} - -impl From>> for StorageEntry> { - fn from(response: WorkerResponse>) -> Self { - match response { - WorkerResponse::ChainStorage(key, value, proof) => StorageEntry { key, value, proof }, - _ => StorageEntry::default(), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn opaque_call_encodes_correctly() { - let call_tuple = ([1u8, 2u8], 5u8); - let call = OpaqueCall::from_tuple(&call_tuple); - assert_eq!(call.encode(), call_tuple.encode()) - } -} diff --git a/tee-worker/bitacross/core-primitives/types/src/parentchain/events.rs b/tee-worker/bitacross/core-primitives/types/src/parentchain/events.rs deleted file mode 100644 index 919f2b2b29..0000000000 --- a/tee-worker/bitacross/core-primitives/types/src/parentchain/events.rs +++ /dev/null @@ -1,195 +0,0 @@ -use super::alloc::{format, vec::Vec}; -use crate::{AccountId, Balance, BlockNumber, Hash, MrEnclave, ShardIdentifier, WorkerType}; -use codec::{Decode, Encode}; -use core::fmt::Debug; -use itp_utils::{hex::ToHexPrefixed, stringify::account_id_to_string}; -use litentry_primitives::{Address32, Identity}; -use substrate_api_client::ac_node_api::StaticEvent; - -#[derive(Encode, Decode, Debug)] -pub struct ExtrinsicSuccess; - -impl StaticEvent for ExtrinsicSuccess { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicSuccess"; -} - -#[derive(Encode, Decode)] -pub struct ExtrinsicFailed; - -impl StaticEvent for ExtrinsicFailed { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicFailed"; -} - -#[derive(Encode, Decode, Debug)] -pub struct BalanceTransfer { - pub from: AccountId, - pub to: AccountId, - pub amount: Balance, -} - -impl core::fmt::Display for BalanceTransfer { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!( - "BalanceTransfer :: from: {}, to: {}, amount: {}", - account_id_to_string::(&self.from), - account_id_to_string::(&self.to), - self.amount - ); - write!(f, "{}", message) - } -} - -impl StaticEvent for BalanceTransfer { - const PALLET: &'static str = "Balances"; - const EVENT: &'static str = "Transfer"; -} - -// Teebag pallet events -#[derive(Encode, Decode, Debug)] -pub struct ParentchainBlockProcessed { - pub shard: ShardIdentifier, - pub block_number: BlockNumber, - pub block_hash: Hash, - pub task_merkle_root: Hash, -} - -impl core::fmt::Display for ParentchainBlockProcessed { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!( - "ParentchainBlockProcessed :: nr {} shard: {}, merkle: {:?}, block hash {:?}", - self.block_number, self.shard, self.task_merkle_root, self.block_hash - ); - write!(f, "{}", message) - } -} - -impl StaticEvent for ParentchainBlockProcessed { - const PALLET: &'static str = "Teebag"; - const EVENT: &'static str = "ParentchainBlockProcessed"; -} - -#[derive(Encode, Decode, Debug)] -pub struct EnclaveUnauthorized { - pub worker_type: WorkerType, - pub mrenclave: MrEnclave, -} - -impl core::fmt::Display for EnclaveUnauthorized { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!( - "EnclaveUnauthorized :: worker_type: {:?}, mrenclave: {}", - self.worker_type, - self.mrenclave.to_hex() - ); - write!(f, "{}", message) - } -} - -impl StaticEvent for EnclaveUnauthorized { - const PALLET: &'static str = "Teebag"; - const EVENT: &'static str = "EnclaveUnauthorized"; -} - -#[derive(Encode, Decode, Debug)] -pub struct EnclaveAdded { - pub who: Address32, - pub worker_type: WorkerType, - pub url: Vec, -} - -impl core::fmt::Display for EnclaveAdded { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!( - "EnclaveAdded :: who: {:?}, worker_type: {:?}, url: {:?}", - self.who, self.worker_type, self.url - ); - write!(f, "{}", message) - } -} - -impl StaticEvent for EnclaveAdded { - const PALLET: &'static str = "Teebag"; - const EVENT: &'static str = "EnclaveAdded"; -} - -#[derive(Encode, Decode, Debug)] -pub struct EnclaveRemoved { - pub who: Address32, -} - -impl core::fmt::Display for EnclaveRemoved { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!("EnclaveRemoved :: who: {:?}", self.who); - write!(f, "{}", message) - } -} - -impl StaticEvent for EnclaveRemoved { - const PALLET: &'static str = "Teebag"; - const EVENT: &'static str = "EnclaveRemoved"; -} - -// Bitacross pallet events - -#[derive(Encode, Decode, Debug)] -pub struct RelayerAdded { - pub who: Identity, -} - -impl core::fmt::Display for RelayerAdded { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(account_id) = self.who.to_account_id() { - let message = format!("RelayerAdded :: account_id: {:?}", account_id); - write!(f, "{}", message) - } else { - write!(f, "RelayerAdded :: account_id: None") - } - } -} - -impl StaticEvent for RelayerAdded { - const PALLET: &'static str = "Bitacross"; - const EVENT: &'static str = "RelayerAdded"; -} - -#[derive(Encode, Decode, Debug)] -pub struct RelayerRemoved { - pub who: Identity, -} - -impl core::fmt::Display for RelayerRemoved { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(account_id) = self.who.to_account_id() { - let message = format!("RelayerRemoved :: account_id: {:?}", account_id); - write!(f, "{}", message) - } else { - write!(f, "RelayerRemoved :: account_id: None") - } - } -} - -impl StaticEvent for RelayerRemoved { - const PALLET: &'static str = "Bitacross"; - const EVENT: &'static str = "RelayerRemoved"; -} - -#[derive(Encode, Decode, Debug)] -pub struct BtcWalletGenerated { - pub pub_key: [u8; 33], - pub account_id: AccountId, -} - -impl core::fmt::Display for BtcWalletGenerated { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let account_id = account_id_to_string::(&self.account_id); - let message = format!("BtcWalletGenerated :: account_id: {:?}", account_id); - write!(f, "{}", message) - } -} - -impl StaticEvent for BtcWalletGenerated { - const PALLET: &'static str = "Bitacross"; - const EVENT: &'static str = "BtcWalletGenerated"; -} diff --git a/tee-worker/bitacross/core-primitives/types/src/parentchain/mod.rs b/tee-worker/bitacross/core-primitives/types/src/parentchain/mod.rs deleted file mode 100644 index 217466d2ff..0000000000 --- a/tee-worker/bitacross/core-primitives/types/src/parentchain/mod.rs +++ /dev/null @@ -1,216 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod events; - -use crate::OpaqueCall; -use alloc::vec::Vec; -use codec::{Decode, Encode}; -use core::fmt::Debug; -use events::{ - BalanceTransfer, BtcWalletGenerated, EnclaveAdded, EnclaveRemoved, EnclaveUnauthorized, - RelayerAdded, RelayerRemoved, -}; -use itp_stf_primitives::traits::{IndirectExecutor, TrustedCallVerification}; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; -use sp_core::{bounded::alloc, H256}; -use sp_runtime::{generic::Header as HeaderG, traits::BlakeTwo256, MultiAddress, MultiSignature}; - -pub type StorageProof = Vec>; - -// Basic Types. -pub type Index = u32; -pub type Balance = u128; -pub type Hash = sp_core::H256; - -// Account Types. -pub type AccountId = sp_core::crypto::AccountId32; -pub type AccountData = pallet_balances::AccountData; -pub type AccountInfo = frame_system::AccountInfo; -pub type Address = MultiAddress; - -// todo! make generic -/// The type used to represent the kinds of proxying allowed. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)] -pub enum ProxyType { - Any, - NonTransfer, - Governance, - Staking, -} - -// Block Types -pub type BlockNumber = u32; -pub type Header = HeaderG; -pub type BlockHash = sp_core::H256; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -#[derive(Encode, Decode, Copy, Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub enum ParentchainId { - /// The Litentry Parentchain, the trust root of the enclave and serving finality to sidechains. - #[codec(index = 0)] - Litentry, - /// A target chain containing custom business logic. - #[codec(index = 1)] - TargetA, - /// Another target chain containing custom business logic. - #[codec(index = 2)] - TargetB, -} - -#[cfg(feature = "std")] -impl std::fmt::Display for ParentchainId { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - let message = match self { - ParentchainId::Litentry => "Litentry", - ParentchainId::TargetA => "TargetA", - ParentchainId::TargetB => "TargetB", - }; - write!(f, "{}", message) - } -} - -pub trait IdentifyParentchain { - fn parentchain_id(&self) -> ParentchainId; -} - -pub trait FilterEvents { - type Error: From + core::fmt::Debug; - - fn get_transfer_events(&self) -> core::result::Result, Self::Error>; - - fn get_enclave_unauthorized_events(&self) -> Result, Self::Error>; - - fn get_relayer_added_events(&self) -> Result, Self::Error>; - - fn get_relayers_removed_events(&self) -> Result, Self::Error>; - - fn get_enclave_added_events(&self) -> Result, Self::Error>; - - fn get_enclave_removed_events(&self) -> Result, Self::Error>; - - fn get_btc_wallet_generated_events(&self) -> Result, Self::Error>; -} - -pub trait HandleParentchainEvents -where - Executor: IndirectExecutor, - TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, -{ - fn handle_events( - executor: &Executor, - events: impl FilterEvents, - ) -> core::result::Result, Error>; -} - -#[derive(Debug)] -pub enum ParentchainEventProcessingError { - ShieldFundsFailure, - FunctionalityDisabled, - EnclaveUnauthorizedFailure, - RelayerAddFailure, - RelayerRemoveFailure, - EnclaveAddFailure, - EnclaveRemoveFailure, - BtcWalletGeneratedFailure, -} - -impl core::fmt::Display for ParentchainEventProcessingError { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = match &self { - ParentchainEventProcessingError::ShieldFundsFailure => - "Parentchain Event Processing Error: ShieldFundsFailure", - ParentchainEventProcessingError::FunctionalityDisabled => - "Parentchain Event Processing Error: FunctionalityDisabled", - ParentchainEventProcessingError::EnclaveUnauthorizedFailure => - "Parentchain Event Processing Error: EnclaveUnauthorizedFailure", - ParentchainEventProcessingError::RelayerAddFailure => - "Parentchain Event Processing Error: RelayerAddFailure", - ParentchainEventProcessingError::RelayerRemoveFailure => - "Parentchain Event Processing Error: RelayerRemoveFailure", - ParentchainEventProcessingError::EnclaveAddFailure => - "Parentchain Event Processing Error: EnclaveAddFailure", - ParentchainEventProcessingError::EnclaveRemoveFailure => - "Parentchain Event Processing Error: EnclaveRemoveFailure", - ParentchainEventProcessingError::BtcWalletGeneratedFailure => - "Parentchain Event Processing Error: BtcWalletGeneratedFailure", - }; - write!(f, "{}", message) - } -} - -impl From for () { - fn from(_: ParentchainEventProcessingError) -> Self {} -} - -/// a wrapper to target calls to specific parentchains -#[derive(Encode, Debug, Clone, PartialEq, Eq)] -pub enum ParentchainCall { - Litentry(OpaqueCall), - TargetA(OpaqueCall), - TargetB(OpaqueCall), -} - -impl ParentchainCall { - pub fn as_litentry(&self) -> Option { - if let Self::Litentry(call) = self { - Some(call.clone()) - } else { - None - } - } - pub fn as_target_a(&self) -> Option { - if let Self::TargetA(call) = self { - Some(call.clone()) - } else { - None - } - } - pub fn as_target_b(&self) -> Option { - if let Self::TargetB(call) = self { - Some(call.clone()) - } else { - None - } - } - pub fn as_opaque_call_for(&self, parentchain_id: ParentchainId) -> Option { - match parentchain_id { - ParentchainId::Litentry => - if let Self::Litentry(call) = self { - Some(call.clone()) - } else { - None - }, - ParentchainId::TargetA => - if let Self::TargetA(call) = self { - Some(call.clone()) - } else { - None - }, - ParentchainId::TargetB => - if let Self::TargetB(call) = self { - Some(call.clone()) - } else { - None - }, - } - } -} diff --git a/tee-worker/bitacross/core-primitives/utils/Cargo.toml b/tee-worker/bitacross/core-primitives/utils/Cargo.toml deleted file mode 100644 index 5fb370797f..0000000000 --- a/tee-worker/bitacross/core-primitives/utils/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "itp-utils" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -homepage = "https://litentry.com/" -repository = "https://github.com/litentry/litentry-parachain" -license = "Apache-2.0" -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -litentry-hex-utils = { path = "../../../../common/utils/hex", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "hex/std", -] diff --git a/tee-worker/bitacross/core/direct-rpc-client/Cargo.toml b/tee-worker/bitacross/core/direct-rpc-client/Cargo.toml index cc468cf03e..0205299ad8 100644 --- a/tee-worker/bitacross/core/direct-rpc-client/Cargo.toml +++ b/tee-worker/bitacross/core/direct-rpc-client/Cargo.toml @@ -1,28 +1,26 @@ [package] -name = "itc-direct-rpc-client" +name = "bc-itc-direct-rpc-client" version = "0.1.0" authors = ['Trust Computing GmbH '] edition = "2021" [dependencies] -# sgx dependencies -rustls_sgx = { package = "rustls", optional = true, git = "https://github.com/mesalock-linux/rustls", tag = "sgx_1.1.3", features = ["dangerous_configuration"] } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -tungstenite_sgx = { package = "tungstenite", optional = true, git = "https://github.com/integritee-network/tungstenite-rs-sgx", branch = "sgx-experimental", features = ["rustls-tls-webpki-roots"] } -webpki_sgx = { package = "webpki", optional = true, git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } +rustls_sgx = { workspace = true, features = ["dangerous_configuration"], optional = true } +sgx_tstd = { workspace = true, optional = true } +tungstenite_sgx = { workspace = true, optional = true } +webpki_sgx = { workspace = true, optional = true } -# no-std dependencies -log = { version = "0.4", default-features = false } -serde_json = { version = "1.0", default-features = false } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } +log = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } -# std dependencies -rustls = { version = "0.19", optional = true, features = ["dangerous_configuration"] } -tungstenite = { version = "0.15.0", optional = true, features = ["rustls-tls-webpki-roots"] } -webpki = { version = "0.21", optional = true } +rustls = { workspace = true, features = ["dangerous_configuration"], optional = true } +tungstenite = { workspace = true, features = ["rustls-tls-webpki-roots"], optional = true } +webpki = { workspace = true, optional = true } -# local dependencies -itp-rpc = { path = "../../core-primitives/rpc", default-features = false } +itp-rpc = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } [features] default = ["std"] @@ -39,5 +37,7 @@ std = [ "tungstenite", "url/std", "itp-rpc/std", + "itp-types/std", + "itp-utils/std", "log/std", ] diff --git a/tee-worker/bitacross/core/direct-rpc-server/Cargo.toml b/tee-worker/bitacross/core/direct-rpc-server/Cargo.toml index ca46e22564..c913c9e6b6 100644 --- a/tee-worker/bitacross/core/direct-rpc-server/Cargo.toml +++ b/tee-worker/bitacross/core/direct-rpc-server/Cargo.toml @@ -1,32 +1,26 @@ [package] -name = "itc-direct-rpc-server" +name = "bc-itc-direct-rpc-server" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +serde_json = { workspace = true } +sp-runtime = { workspace = true } -# local -itc-tls-websocket-server = { path = "../tls-websocket-server", default-features = false } -itp-rpc = { path = "../../core-primitives/rpc", default-features = false } -itp-types = { default-features = false, path = "../../core-primitives/types" } -itp-utils = { default-features = false, path = "../../core-primitives/utils" } +itc-tls-websocket-server = { workspace = true } +itp-rpc = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } -thiserror = { version = "1.0", optional = true } +jsonrpc-core = { workspace = true, optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/core/offchain-worker-executor/Cargo.toml b/tee-worker/bitacross/core/offchain-worker-executor/Cargo.toml index a1acb1f113..db752e7e20 100644 --- a/tee-worker/bitacross/core/offchain-worker-executor/Cargo.toml +++ b/tee-worker/bitacross/core/offchain-worker-executor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "itc-offchain-worker-executor" +name = "bc-itc-offchain-worker-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" @@ -7,43 +7,34 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sgx_tstd = { workspace = true, optional = true } -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } +itc-parentchain-light-client = { workspace = true } +itp-extrinsics-factory = { workspace = true } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../core-primitives/stf-executor", default-features = false } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } -# local dependencies -itc-parentchain-light-client = { path = "../../core/parentchain/light-client", default-features = false } -itp-extrinsics-factory = { path = "../../core-primitives/extrinsics-factory", default-features = false } -itp-stf-executor = { path = "../../core-primitives/stf-executor", default-features = false } -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 } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } - -# Substrate dependencies -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# no-std compatible libraries -log = { version = "0.4", default-features = false } +sp-runtime = { workspace = true } [dev-dependencies] -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -itc-parentchain-light-client = { path = "../../core/parentchain/light-client", features = ["mocks"] } -itp-extrinsics-factory = { path = "../../core-primitives/extrinsics-factory", features = ["mocks"] } -itp-stf-executor = { path = "../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../core-primitives/test" } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", features = ["mocks"] } -itp-stf-interface = { path = "../../core-primitives/stf-interface", features = ["mocks"] } -itp-sgx-externalities = { path = "../../core-primitives/substrate-sgx/externalities" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true, features = ["std"] } +itc-parentchain-light-client = { workspace = true, features = ["std", "mocks"] } +itp-extrinsics-factory = { workspace = true, features = ["std", "mocks"] } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../core-primitives/stf-executor", features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../../core-primitives/top-pool-author", features = ["std", "mocks"] } +itp-stf-interface = { workspace = true, features = ["std", "mocks"] } +itp-sgx-externalities = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } [features] default = ["std"] diff --git a/tee-worker/bitacross/core/parentchain/block-import-dispatcher/Cargo.toml b/tee-worker/bitacross/core/parentchain/block-import-dispatcher/Cargo.toml index 66f23ad2c8..28261ceb76 100644 --- a/tee-worker/bitacross/core/parentchain/block-import-dispatcher/Cargo.toml +++ b/tee-worker/bitacross/core/parentchain/block-import-dispatcher/Cargo.toml @@ -1,48 +1,36 @@ [package] -name = "itc-parentchain-block-import-dispatcher" +name = "bc-itc-parentchain-block-import-dispatcher" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } -# local dependencies -itc-parentchain-block-importer = { path = "../block-importer", default-features = false } -itp-import-queue = { path = "../../../core-primitives/import-queue", default-features = false } +itc-parentchain-block-importer = { package = "bc-itc-parentchain-block-importer", path = "../block-importer", default-features = false } +itp-import-queue = { workspace = true } -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# crates.io std-only compatible libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries -log = { version = "0.4", default-features = false } +log = { workspace = true } [dev-dependencies] -itc-parentchain-block-importer = { path = "../block-importer", features = ["mocks"] } +itc-parentchain-block-importer = { package = "bc-itc-parentchain-block-importer", path = "../block-importer", features = ["mocks"] } [features] default = ["std"] std = [ - # local "itc-parentchain-block-importer/std", "itp-import-queue/std", - # no-std compatible libraries "log/std", - # std-only compatible libraries "thiserror", ] sgx = [ - # sgx "sgx_tstd", - # local "itc-parentchain-block-importer/sgx", "itp-import-queue/sgx", - # sgx enabled external libraries "thiserror_sgx", ] diff --git a/tee-worker/bitacross/core/parentchain/block-importer/Cargo.toml b/tee-worker/bitacross/core/parentchain/block-importer/Cargo.toml index 9028d78799..9ae50d53f7 100644 --- a/tee-worker/bitacross/core/parentchain/block-importer/Cargo.toml +++ b/tee-worker/bitacross/core/parentchain/block-importer/Cargo.toml @@ -1,42 +1,33 @@ [package] -name = "itc-parentchain-block-importer" +name = "bc-itc-parentchain-block-importer" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# local dependencies -ita-stf = { path = "../../../app-libs/stf", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../indirect-calls-executor", default-features = false } -itc-parentchain-light-client = { path = "../light-client", default-features = false } -itp-enclave-metrics = { path = "../../../core-primitives/enclave-metrics", default-features = false } -itp-extrinsics-factory = { path = "../../../core-primitives/extrinsics-factory", default-features = false } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", default-features = false } -itp-stf-interface = { path = "../../../core-primitives/stf-interface", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# crates.io std-only compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +ita-stf = { package = "bc-ita-stf", path = "../../../app-libs/stf", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "bc-itc-parentchain-indirect-calls-executor", path = "../indirect-calls-executor", default-features = false } +itc-parentchain-light-client = { workspace = true } +itp-enclave-metrics = { workspace = true } +itp-extrinsics-factory = { workspace = true } +itp-ocall-api = { workspace = true } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } +itp-stf-interface = { workspace = true } +itp-types = { workspace = true } + +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-runtime = { workspace = true } [features] default = ["std"] std = [ - # local "ita-stf/std", "itc-parentchain-indirect-calls-executor/std", "itc-parentchain-light-client/std", @@ -45,25 +36,20 @@ std = [ "itp-stf-executor/std", "itp-stf-interface/std", "itp-types/std", - # no-std compatible libraries "codec/std", "log/std", "sp-runtime/std", - # std compatible external "thiserror", "itp-ocall-api/std", ] sgx = [ - # sgx "sgx_tstd", - # local "ita-stf/sgx", "itc-parentchain-indirect-calls-executor/sgx", "itc-parentchain-light-client/sgx", "itp-enclave-metrics/sgx", "itp-extrinsics-factory/sgx", "itp-stf-executor/sgx", - # sgx enabled external libraries "thiserror_sgx", ] diff --git a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/Cargo.toml b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/Cargo.toml index 0dc42b0d9d..9ff5496a13 100644 --- a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/Cargo.toml +++ b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/Cargo.toml @@ -1,56 +1,50 @@ [package] -name = "itc-parentchain-indirect-calls-executor" +name = "bc-itc-parentchain-indirect-calls-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } -# local dependencies -itp-api-client-types = { path = "../../../core-primitives/node-api/api-client-types", default-features = false } -itp-node-api = { path = "../../../core-primitives/node-api", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-runtime-primitives = { path = "../../../core-primitives/sgx-runtime-primitives", default-features = false } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", default-features = false } -itp-stf-primitives = { path = "../../../core-primitives/stf-primitives", default-features = false } -itp-test = { path = "../../../core-primitives/test", default-features = false } -itp-top-pool-author = { path = "../../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } +itp-api-client-types = { workspace = true } +itp-node-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-runtime-primitives = { workspace = true } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } +itp-stf-primitives = { workspace = true } +itp-test = { workspace = true } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } -# sgx enabled external libraries -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +futures_sgx = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -futures = { version = "0.3.8", optional = true } -thiserror = { version = "1.0", optional = true } +futures = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } -# no-std compatible libraries bs58 = { version = "0.4.0", default-features = false, features = ["alloc"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } -# substrate dep -binary-merkle-tree = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +binary-merkle-tree = { workspace = true } +sp-runtime = { workspace = true } # litentry bc-enclave-registry = { path = "../../../bitacross/core/bc-enclave-registry", default-features = false } bc-relayer-registry = { path = "../../../bitacross/core/bc-relayer-registry", default-features = false } bc-signer-registry = { path = "../../../bitacross/core/bc-signer-registry", default-features = false } -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +litentry-primitives = { workspace = true } [dev-dependencies] -env_logger = "0.9.0" -itp-node-api = { path = "../../../core-primitives/node-api", features = ["mocks"] } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../../core-primitives/test" } -itp-top-pool-author = { path = "../../../core-primitives/top-pool-author", features = ["mocks"] } -itc-parentchain-test = { path = "../../../core/parentchain/test" } +env_logger = { workspace = true } +itp-node-api = { workspace = true, features = ["std", "mocks"] } +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../../../core-primitives/stf-executor", features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../../../core-primitives/top-pool-author", features = ["std", "mocks"] } +itc-parentchain-test = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/executor.rs b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/executor.rs index 5fbc7f6942..009a996f57 100644 --- a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/executor.rs +++ b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/executor.rs @@ -42,7 +42,7 @@ use itp_stf_primitives::{ use itp_top_pool_author::traits::AuthorApi; use itp_types::{ parentchain::{HandleParentchainEvents, ParentchainId}, - OpaqueCall, RsaRequest, ShardIdentifier, H256, + MrEnclave, OpaqueCall, RsaRequest, ShardIdentifier, H256, }; use log::*; use sp_runtime::traits::{Block as ParentchainBlockTrait, Header, Keccak256}; @@ -70,6 +70,7 @@ pub struct IndirectCallsExecutor< pub(crate) top_pool_author: Arc, pub(crate) node_meta_data_provider: Arc, pub parentchain_id: ParentchainId, + parentchain_event_handler: ParentchainEventHandler, pub relayer_registry_updater: Arc, pub signer_registry_updater: Arc, pub enclave_registry_updater: Arc, @@ -112,6 +113,7 @@ impl< top_pool_author: Arc, node_meta_data_provider: Arc, parentchain_id: ParentchainId, + parentchain_event_handler: ParentchainEventHandler, relayer_registry_updater: Arc, signer_registry_updater: Arc, enclave_registry_updater: Arc, @@ -122,6 +124,7 @@ impl< top_pool_author, node_meta_data_provider, parentchain_id, + parentchain_event_handler, relayer_registry_updater, signer_registry_updater, enclave_registry_updater, @@ -164,7 +167,8 @@ impl< NodeMetadataProvider: AccessNodeMetadata, NodeMetadataProvider::MetadataType: NodeMetadataTrait + Clone, EventCreator: EventsFromMetadata, - ParentchainEventHandler: HandleParentchainEvents, + ParentchainEventHandler: + HandleParentchainEvents>, TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, G: PartialEq + Encode + Decode + Debug + Clone + Send + Sync, RRU: RelayerRegistryUpdater, @@ -191,9 +195,7 @@ impl< })? .ok_or_else(|| Error::Other("Could not create events from metadata".into()))?; - let processed_events = ParentchainEventHandler::handle_events(self, events)?; - - debug!("successfully processed {} indirect invocations", processed_events.len()); + let processed_events = self.parentchain_event_handler.handle_events(self, events)?; if self.parentchain_id == ParentchainId::Litentry { // Include a processed parentchain block confirmation for each block. @@ -287,6 +289,10 @@ impl< Ok(self.stf_enclave_signer.get_enclave_account()?) } + fn get_mrenclave(&self) -> Result { + Ok(self.stf_enclave_signer.get_mrenclave()?) + } + fn get_default_shard(&self) -> ShardIdentifier { self.top_pool_author.list_handled_shards().first().copied().unwrap_or_default() } @@ -321,9 +327,8 @@ mod test { use bc_signer_registry::SignerRegistry; use codec::Encode; - use itp_node_api::{ - api_client::ExtrinsicParams, - metadata::{metadata_mocks::NodeMetadataMock, provider::NodeMetadataRepository}, + use itp_node_api::metadata::{ + metadata_mocks::NodeMetadataMock, provider::NodeMetadataRepository, }; use itp_sgx_crypto::mocks::KeyRepositoryMock; use itp_stf_executor::mocks::StfEnclaveSignerMock; @@ -352,10 +357,6 @@ mod test { EnclaveRegistry, >; - type Seed = [u8; 32]; - - const TEST_SEED: Seed = *b"12345678901234567890123456789012"; - #[test] fn ensure_empty_events_vec_triggers_zero_filled_merkle_root() { // given @@ -409,6 +410,7 @@ mod test { let stf_enclave_signer = Arc::new(TestStfEnclaveSigner::new(mr_enclave)); let top_pool_author = Arc::new(TestTopPoolAuthor::default()); let node_metadata_repo = Arc::new(NodeMetadataRepository::new(metadata)); + let parentchain_event_handler = MockParentchainEventHandler {}; let relayer_registry = Arc::new(RelayerRegistry::new(Default::default())); let signer_registry = Arc::new(SignerRegistry::new(Default::default())); let enclave_registry = Arc::new(EnclaveRegistry::new(Default::default())); @@ -419,6 +421,7 @@ mod test { top_pool_author.clone(), node_metadata_repo, ParentchainId::Litentry, + parentchain_event_handler, relayer_registry, signer_registry, enclave_registry, diff --git a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/mock.rs b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/mock.rs index 1d3e044e31..d49e12b18f 100644 --- a/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/mock.rs +++ b/tee-worker/bitacross/core/parentchain/indirect-calls-executor/src/mock.rs @@ -15,10 +15,7 @@ use itp_sgx_runtime_primitives::types::{AccountId, Balance}; use itp_stf_primitives::{traits::IndirectExecutor, types::Signature}; use itp_test::mock::stf_mock::{GetterMock, TrustedCallMock, TrustedCallSignedMock}; use itp_types::{ - parentchain::{ - events::{BalanceTransfer, EnclaveUnauthorized}, - FilterEvents, HandleParentchainEvents, - }, + parentchain::{events::*, FilterEvents, HandleParentchainEvents}, Address, RsaRequest, ShardIdentifier, H256, }; use log::*; @@ -134,19 +131,42 @@ pub struct MockEvents; impl FilterEvents for MockEvents { type Error = (); - fn get_transfer_events(&self) -> Result, Self::Error> { - let transfer = BalanceTransfer { - to: [0u8; 32].into(), - from: [0u8; 32].into(), - amount: Balance::default(), - }; - Ok(Vec::from([transfer])) + fn get_link_identity_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_vc_requested_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_deactivate_identity_events( + &self, + ) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_activate_identity_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) } fn get_enclave_unauthorized_events(&self) -> Result, Self::Error> { Ok(Vec::new()) } + fn get_opaque_task_posted_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_assertion_created_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_parentchain_block_proccessed_events( + &self, + ) -> Result, Self::Error> { + Ok(Vec::new()) + } + fn get_relayer_added_events( &self, ) -> Result, Self::Error> { @@ -198,7 +218,10 @@ where EnclaveRegistry, >, { + type Output = Vec; + fn handle_events( + &self, _: &Executor, _: impl itp_types::parentchain::FilterEvents, ) -> core::result::Result, Error> { diff --git a/tee-worker/bitacross/core/parentchain/light-client/Cargo.toml b/tee-worker/bitacross/core/parentchain/light-client/Cargo.toml deleted file mode 100644 index fa67aee044..0000000000 --- a/tee-worker/bitacross/core/parentchain/light-client/Cargo.toml +++ /dev/null @@ -1,71 +0,0 @@ -[package] -name = "itc-parentchain-light-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "chain-error"] } -finality-grandpa = { version = "0.16.0", default-features = false, features = ["derive-codec"] } -log = { version = "0.4", default-features = false } -thiserror = { version = "1.0.26", optional = true } - -# sgx-deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["untrusted_fs"], optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# local deps -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -itp-storage = { path = "../../../core-primitives/storage", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } - -# substrate deps -sp-consensus-grandpa = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# test & mock dependencies -itc-parentchain-test = { optional = true, default-features = false, path = "../../../core/parentchain/test" } -# We can't really make this optional due to feature flag complexities. -itp-sgx-temp-dir = { version = "0.1", default-features = false, path = "../../../core-primitives/sgx/temp-dir" } -itp-test = { optional = true, default-features = false, features = ["sgx"], path = "../../../core-primitives/test" } - -[dev-dependencies] -itc-parentchain-test = { path = "../../../core/parentchain/test" } -itp-test = { path = "../../../core-primitives/test" } -itp-sgx-temp-dir = { version = "0.1", path = "../../../core-primitives/sgx/temp-dir" } - - -[features] -default = ["std"] -std = [ - "codec/std", - "log/std", - "finality-grandpa/std", - "thiserror", - - # substrate deps - "sp-consensus-grandpa/std", - "sp-runtime/std", - - # local deps - "itp-ocall-api/std", - "itp-storage/std", - "itp-sgx-io/std", - "itp-types/std", - # mock deps - "itp-sgx-temp-dir/std", -] -sgx = [ - "sgx_tstd", - "thiserror-sgx", - "itp-sgx-io/sgx", - "itp-storage/sgx", - "itp-sgx-temp-dir/sgx", -] -mocks = [ - "itc-parentchain-test", -] - -test = ["mocks", "itp-test"] diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/concurrent_access.rs b/tee-worker/bitacross/core/parentchain/light-client/src/concurrent_access.rs deleted file mode 100644 index fda60d74b0..0000000000 --- a/tee-worker/bitacross/core/parentchain/light-client/src/concurrent_access.rs +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Concurrent access mechanisms that ensure mutually exclusive read/write access -//! to the light-client (validator) by employing RwLocks under the hood. - -#[cfg(feature = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - ExtrinsicSender as ExtrinsicSenderTrait, LightClientSealing, LightClientState, - LightValidationState, Validator as ValidatorTrait, -}; -use finality_grandpa::BlockNumberOps; -use itp_types::parentchain::{IdentifyParentchain, ParentchainId}; -use sp_runtime::traits::{Block as ParentchainBlockTrait, NumberFor}; -use std::{marker::PhantomData, sync::Arc}; - -/// Retrieve an exclusive lock on a validator for either read or write access. -/// -/// In order to hide the whole locks mechanics, we provide an interface that allows executing -/// either a mutating, or a non-mutating function on the validator. -/// The reason we have this additional wrapper around `SealedIO`, is that we need -/// to guard against concurrent access by using RWLocks (which `SealedIO` does not do). -pub trait ValidatorAccess -where - ParentchainBlock: ParentchainBlockTrait, - NumberFor: BlockNumberOps, -{ - type ValidatorType: ValidatorTrait - + LightClientState - + ExtrinsicSenderTrait; - - /// Execute a non-mutating function on the validator. - fn execute_on_validator(&self, getter_function: F) -> Result - where - F: FnOnce(&Self::ValidatorType) -> Result; - - /// Execute a mutating function on the validator. - fn execute_mut_on_validator(&self, mutating_function: F) -> Result - where - F: FnOnce(&mut Self::ValidatorType) -> Result; -} - -/// Implementation of a validator access based on a global lock and corresponding file. -#[derive(Debug)] -pub struct ValidatorAccessor { - seal: Arc, - light_validation: RwLock, - _phantom: PhantomData<(LightClientSeal, Validator, ParentchainBlock)>, -} - -impl - ValidatorAccessor -{ - pub fn new(validator: Validator, seal: Arc) -> Self { - ValidatorAccessor { - light_validation: RwLock::new(validator), - seal, - _phantom: Default::default(), - } - } -} - -impl IdentifyParentchain - for ValidatorAccessor -{ - fn parentchain_id(&self) -> ParentchainId { - (*self.seal).parentchain_id() - } -} - -impl ValidatorAccess - for ValidatorAccessor -where - Validator: ValidatorTrait - + LightClientState - + ExtrinsicSenderTrait, - Seal: LightClientSealing>, - ParentchainBlock: ParentchainBlockTrait, - NumberFor: BlockNumberOps, -{ - type ValidatorType = Validator; - - fn execute_on_validator(&self, getter_function: F) -> Result - where - F: FnOnce(&Self::ValidatorType) -> Result, - { - let light_validation_lock = - self.light_validation.write().map_err(|_| Error::PoisonedLock)?; - getter_function(&light_validation_lock) - } - - fn execute_mut_on_validator(&self, mutating_function: F) -> Result - where - F: FnOnce(&mut Self::ValidatorType) -> Result, - { - let mut light_validation_lock = - self.light_validation.write().map_err(|_| Error::PoisonedLock)?; - let result = mutating_function(&mut light_validation_lock); - self.seal.seal(light_validation_lock.get_state())?; - result - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::mocks::{ - validator_mock::ValidatorMock, validator_mock_seal::LightValidationStateSealMock, - }; - use itp_types::Block; - - type TestAccessor = ValidatorAccessor; - - #[test] - fn execute_with_and_without_mut_in_single_thread_works() { - let validator_mock = ValidatorMock::default(); - let seal = LightValidationStateSealMock::new(); - let accessor = TestAccessor::new(validator_mock, seal.into()); - - let _read_result = accessor.execute_on_validator(|_v| Ok(())).unwrap(); - let _write_result = accessor.execute_mut_on_validator(|_v| Ok(())).unwrap(); - } -} diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/light_client_init_params.rs b/tee-worker/bitacross/core/parentchain/light-client/src/light_client_init_params.rs deleted file mode 100644 index 114d684382..0000000000 --- a/tee-worker/bitacross/core/parentchain/light-client/src/light_client_init_params.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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 codec::{Decode, Encode}; -use sp_consensus_grandpa::AuthorityList; -use std::vec::Vec; - -#[derive(Encode, Decode, Clone)] -pub struct GrandpaParams
{ - pub genesis_header: Header, - pub authorities: AuthorityList, - pub authority_proof: Vec>, -} - -impl
GrandpaParams
{ - pub fn new( - genesis_header: Header, - authorities: AuthorityList, - authority_proof: Vec>, - ) -> Self { - Self { genesis_header, authorities, authority_proof } - } -} - -#[derive(Encode, Decode, Clone)] -pub struct SimpleParams
{ - pub genesis_header: Header, -} - -impl
SimpleParams
{ - pub fn new(genesis_header: Header) -> Self { - Self { genesis_header } - } -} diff --git a/tee-worker/bitacross/core/parentchain/parentchain-crate/Cargo.toml b/tee-worker/bitacross/core/parentchain/parentchain-crate/Cargo.toml index 7670ff4920..1f2146be92 100644 --- a/tee-worker/bitacross/core/parentchain/parentchain-crate/Cargo.toml +++ b/tee-worker/bitacross/core/parentchain/parentchain-crate/Cargo.toml @@ -1,21 +1,19 @@ [package] -name = "itc-parentchain" +name = "bc-itc-parentchain" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "chain-error"] } +codec = { package = "parity-scale-codec", workspace = true, features = ["chain-error"] } -# Parity -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-runtime = { workspace = true } -# local -itc-parentchain-block-import-dispatcher = { path = "../block-import-dispatcher", default-features = false } -itc-parentchain-block-importer = { path = "../block-importer", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../indirect-calls-executor", default-features = false } -itc-parentchain-light-client = { path = "../light-client", default-features = false } -itp-types = { default-features = false, path = "../../../core-primitives/types" } +itc-parentchain-block-import-dispatcher = { package = "bc-itc-parentchain-block-import-dispatcher", path = "../block-import-dispatcher", default-features = false } +itc-parentchain-block-importer = { package = "bc-itc-parentchain-block-importer", path = "../block-importer", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "bc-itc-parentchain-indirect-calls-executor", path = "../indirect-calls-executor", default-features = false } +itc-parentchain-light-client = { workspace = true } +itp-types = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/core/parentchain/parentchain-crate/src/lib.rs b/tee-worker/bitacross/core/parentchain/parentchain-crate/src/lib.rs index 368ee69967..d9e4e07f55 100644 --- a/tee-worker/bitacross/core/parentchain/parentchain-crate/src/lib.rs +++ b/tee-worker/bitacross/core/parentchain/parentchain-crate/src/lib.rs @@ -29,5 +29,3 @@ pub use itc_parentchain_block_importer as block_importer; pub use itc_parentchain_indirect_calls_executor as indirect_calls_executor; pub use itc_parentchain_light_client as light_client; - -pub mod primitives; diff --git a/tee-worker/bitacross/core/parentchain/parentchain-crate/src/primitives.rs b/tee-worker/bitacross/core/parentchain/parentchain-crate/src/primitives.rs deleted file mode 100644 index 6a02c99577..0000000000 --- a/tee-worker/bitacross/core/parentchain/parentchain-crate/src/primitives.rs +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 alloc; - -use crate::light_client::light_client_init_params::{GrandpaParams, SimpleParams}; -use codec::{Decode, Encode}; - -use sp_runtime::traits::Block; - -use itp_types::ShardIdentifier; -pub use itp_types::{parentchain::ParentchainId, Block as ParachainBlock, Block as SolochainBlock}; - -pub type HeaderFor = ::Header; -pub type SolochainHeader = HeaderFor; -pub type ParachainHeader = HeaderFor; -pub type SolochainParams = GrandpaParams; -pub type ParachainParams = SimpleParams; - -/// Initialization primitives, used by both service and enclave. -/// Allows to use a single E-call for the initialization of different parentchain types. -#[derive(Encode, Decode, Clone)] -pub enum ParentchainInitParams { - Solochain { id: ParentchainId, shard: ShardIdentifier, params: SolochainParams }, - Parachain { id: ParentchainId, shard: ShardIdentifier, params: ParachainParams }, -} - -impl ParentchainInitParams { - pub fn id(&self) -> &ParentchainId { - match self { - Self::Solochain { id, .. } => id, - Self::Parachain { id, .. } => id, - } - } - pub fn is_solochain(&self) -> bool { - matches!(self, Self::Solochain { .. }) - } - pub fn is_parachain(&self) -> bool { - matches!(self, Self::Parachain { .. }) - } -} - -impl From<(ParentchainId, ShardIdentifier, SolochainParams)> for ParentchainInitParams { - fn from(value: (ParentchainId, ShardIdentifier, SolochainParams)) -> Self { - Self::Solochain { id: value.0, shard: value.1, params: value.2 } - } -} - -impl From<(ParentchainId, ShardIdentifier, ParachainParams)> for ParentchainInitParams { - fn from(value: (ParentchainId, ShardIdentifier, ParachainParams)) -> Self { - Self::Parachain { id: value.0, shard: value.1, params: value.2 } - } -} diff --git a/tee-worker/bitacross/core/rest-client/Cargo.toml b/tee-worker/bitacross/core/rest-client/Cargo.toml deleted file mode 100644 index d91cd0e5d9..0000000000 --- a/tee-worker/bitacross/core/rest-client/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "itc-rest-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# std dependencies -http = { version = "0.2", optional = true } -http_req = { optional = true, features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } -thiserror = { version = "1.0.26", optional = true } - -# sgx dependencies -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -http_req-sgx = { optional = true, default-features = false, features = ["rust-tls", "sgx"], package = "http_req", git = "https://github.com/integritee-network/http_req" } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# no_std dependencies -base64 = { version = "0.13", default-features = false, features = ["alloc"] } -log = { version = "0.4", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } - -[features] -default = ["std"] -std = [ - # std only - "http", - "http_req", - "thiserror", - # no_std - "url/std", - "base64/std", - "serde/std", - "serde_json/std", - "log/std", -] -sgx = [ - "http-sgx", - "http_req-sgx", - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/bitacross/core/rest-client/src/http_client.rs b/tee-worker/bitacross/core/rest-client/src/http_client.rs deleted file mode 100644 index e45f6a3c88..0000000000 --- a/tee-worker/bitacross/core/rest-client/src/http_client.rs +++ /dev/null @@ -1,584 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{error::Error, Query, RestPath}; -use http::{ - header::{HeaderName, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT}, - HeaderValue, -}; -use http_req::{ - request::{Method, Request}, - response::{Headers, Response}, - tls::Config, - uri::Uri, -}; -use log::*; -use std::{ - collections::HashMap, - convert::TryFrom, - str::FromStr, - string::{String, ToString}, - time::Duration, - vec::Vec, -}; -use url::Url; - -pub type EncodedBody = Vec; - -/// Simple trait to send HTTP request -pub trait SendHttpRequest { - fn send_request( - &self, - base_url: Url, - method: Method, - params: U, - query: Option<&Query<'_>>, - maybe_body: Option, - ) -> Result<(Response, EncodedBody), Error> - where - T: RestPath; -} - -/// Send trait used by the http client to send HTTP request, based on `http_req`. -pub trait Send { - fn execute_send_request( - &self, - request: &mut Request, - writer: &mut Vec, - ) -> Result; -} - -/// HTTP client implementation -/// -/// wrapper for the `http_req` library that adds the necessary headers and body to a request -pub struct HttpClient { - send: SendType, - send_null_body: bool, - timeout: Option, - headers: Headers, - authorization: Option, -} - -/// Default send method. -/// Automatically upgrades to TLS in case the base URL contains 'https' -/// For https requests, the default trusted server's certificates -/// are provided by the default tls configuration of the http_req lib -pub struct DefaultSend; - -impl Send for DefaultSend { - fn execute_send_request( - &self, - request: &mut Request, - writer: &mut Vec, - ) -> Result { - request.send(writer).map_err(Error::HttpReqError) - } -} - -/// Sends a HTTPs request with the server's root certificate(s). -/// The connection will only be established if one of the supplied certificates -/// matches the server's root certificate. -pub struct SendWithCertificateVerification { - root_certificates: Vec, -} - -impl SendWithCertificateVerification { - pub fn new(root_certificates: Vec) -> Self { - SendWithCertificateVerification { root_certificates } - } -} - -impl Send for SendWithCertificateVerification { - fn execute_send_request( - &self, - request: &mut Request, - writer: &mut Vec, - ) -> Result { - let mut cnf = Config::default(); - for cert in self.root_certificates.iter() { - cnf.add_root_cert_content_pem_file(cert)?; - } - - match request.send_with_config(writer, Some(&cnf)) { - Ok(response) => Ok(response), - Err(e) => { - error!( - "SendWithCertificateVerification::execute_send_request received error: {:?}", - &e - ); - Err(Error::HttpReqError(e)) - }, - } - } -} - -impl HttpClient -where - SendType: Send, -{ - pub fn new( - send: SendType, - send_null_body: bool, - timeout: Option, - headers: Option, - authorization: Option, - ) -> Self { - HttpClient { - send, - send_null_body, - timeout, - headers: headers.unwrap_or_else(Headers::new), - authorization, - } - } - - /// Set credentials for HTTP Basic authentication. - pub fn set_auth(&mut self, user: &str, pass: &str) { - let mut s: String = user.to_string(); - s.push(':'); - s.push_str(pass); - self.authorization = Some(format!("Basic {}", base64::encode(&s))); - } - - /// Set HTTP header from string name and value. - /// - /// The header is added to all subsequent GET and POST requests - /// unless the headers are cleared with `clear_headers()` call. - pub fn set_header(&mut self, name: &'static str, value: &str) -> Result<(), Error> { - let header_name = HeaderName::from_str(name).map_err(|_| Error::InvalidValue)?; - let value = HeaderValue::from_str(value).map_err(|_| Error::InvalidValue)?; - - add_to_headers(&mut self.headers, header_name, value); - Ok(()) - } - - /// Clear all previously set headers - pub fn clear_headers(&mut self) { - self.headers = Headers::new(); - } -} - -impl SendHttpRequest for HttpClient -where - SendType: Send, -{ - fn send_request( - &self, - base_url: Url, - method: Method, - params: U, - query: Option<&Query<'_>>, - maybe_body: Option, - ) -> Result<(Response, EncodedBody), Error> - where - T: RestPath, - { - let url = join_url(base_url, T::get_path(params)?.as_str(), query)?; - let uri = Uri::try_from(url.as_str()).map_err(Error::HttpReqError)?; - - trace!("uri: {:?}", uri); - - let mut request = Request::new(&uri); - request.method(method); - - let mut request_headers = Headers::default_http(&uri); - - if let Some(body) = maybe_body.as_ref() { - if self.send_null_body || body != "null" { - let len = HeaderValue::from_str(&body.len().to_string()) - .map_err(|_| Error::RequestError)?; - - add_to_headers(&mut request_headers, CONTENT_LENGTH, len); - add_to_headers( - &mut request_headers, - CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Request Header: invalid characters"), - ); - - trace!("set request body: {}", body); - request.body(body.as_bytes()); // takes body non-owned (!) - } - } else { - debug!("no body to send"); - } - - if let Some(ref auth) = self.authorization { - add_to_headers( - &mut request_headers, - AUTHORIZATION, - HeaderValue::from_str(auth).map_err(|_| Error::RequestError)?, - ); - } - - // add pre-set headers - for (key, value) in self.headers.iter() { - request_headers.insert(key, &value.clone()); - } - - // add user agent header - let pkg_version = env!("CARGO_PKG_VERSION"); - add_to_headers( - &mut request_headers, - USER_AGENT, - HeaderValue::from_str(format!("integritee/{}", pkg_version).as_str()) - .map_err(|_| Error::RequestError)?, - ); - - request.headers(HashMap::from(request_headers)); - - request - .timeout(self.timeout) - .connect_timeout(self.timeout) - .read_timeout(self.timeout) - .write_timeout(self.timeout); - - trace!("request is: {:?}", request); - - let mut writer = Vec::new(); - - let response = self.send.execute_send_request(&mut request, &mut writer)?; - - Ok((response, writer)) - } -} - -fn join_url(base_url: Url, path: &str, params: Option<&Query>) -> Result { - let mut url = base_url.join(path).map_err(|_| Error::UrlError)?; - - if let Some(params) = params { - for &(key, item) in params.iter() { - url.query_pairs_mut().append_pair(key, item); - } - } - - Ok(url) -} - -fn add_to_headers(headers: &mut Headers, key: HeaderName, value: HeaderValue) { - let header_value_str = value.to_str(); - - match header_value_str { - Ok(v) => { - headers.insert(key.as_str(), v); - }, - Err(e) => { - error!("Failed to add header to request: {:?}", e); - }, - } -} - -#[cfg(test)] -mod tests { - - use super::*; - use core::assert_matches::assert_matches; - use http::header::CONNECTION; - use serde::{Deserialize, Serialize}; - use std::vec::Vec; - - const HTTPBIN_ROOT_CERT: &str = include_str!("fixtures/amazon_root_ca_1_v3.pem"); - const COINGECKO_ROOT_CERTIFICATE_BALTIMORE: &str = - include_str!("fixtures/baltimore_cyber_trust_root_v3.pem"); - const COINGECKO_ROOT_CERTIFICATE_LETSENCRYPT: &str = - include_str!("fixtures/lets_encrypt_root_cert.pem"); - - #[test] - fn join_url_adds_query_parameters() { - let base_url = Url::parse("https://example.com").unwrap(); - let path = "api/v2/example_list"; - let query = [("filter", "all"), ("order", ("desc"))]; - - let complete_url = join_url(base_url, path, Some(&query)).unwrap(); - - assert_eq!( - complete_url.as_str(), - "https://example.com/api/v2/example_list?filter=all&order=desc" - ); - } - - #[test] - fn join_url_has_no_query_parameters() { - let base_url = Url::parse("https://example.com").unwrap(); - let path = "api/v2/endpoint"; - let complete_url = join_url(base_url, path, None).unwrap(); - assert_eq!(complete_url.as_str(), "https://example.com/api/v2/endpoint"); - } - - #[test] - fn join_url_with_too_many_slashes() { - let base_url = Url::parse("https://api.mydomain.com").unwrap(); - let path = "/api/v1/post"; - let complete_url = join_url(base_url, path, None).unwrap(); - assert_eq!(complete_url.as_str(), "https://api.mydomain.com/api/v1/post"); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn get_with_parameters() { - #[derive(Serialize, Deserialize, Debug)] - struct RequestArgs { - pub order: String, - pub filter: String, - } - - // Data structure that matches with REST API JSON - #[derive(Serialize, Deserialize, Debug)] - struct HttpBinAnything { - pub args: RequestArgs, - pub origin: String, - pub url: String, - } - - impl RestPath<()> for HttpBinAnything { - fn get_path(_: ()) -> Result { - Ok(format!("anything")) - } - } - - let http_client = HttpClient::new( - DefaultSend {}, - true, - Some(Duration::from_secs(3u64)), - Some(headers_connection_close()), - None, - ); - let base_url = Url::parse("https://httpbin.org").unwrap(); - let query_parameters = [("order", "desc"), ("filter", "all")]; - - let (response, encoded_body) = http_client - .send_request::<(), HttpBinAnything>( - base_url, - Method::GET, - (), - Some(&query_parameters), - None, - ) - .unwrap(); - - let response_body: HttpBinAnything = - deserialize_response_body(encoded_body.as_slice()).unwrap(); - - assert!(response.status_code().is_success()); - assert_eq!(response_body.args.order.as_str(), "desc"); - assert_eq!(response_body.args.filter.as_str(), "all"); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn get_without_parameters() { - // Data structure that matches with REST API JSON - #[derive(Serialize, Deserialize, Debug)] - struct HttpBinAnything { - pub method: String, - pub url: String, - } - - impl RestPath<()> for HttpBinAnything { - fn get_path(_: ()) -> Result { - Ok(format!("anything")) - } - } - - let http_client = HttpClient::new( - DefaultSend {}, - true, - Some(Duration::from_secs(3u64)), - Some(headers_connection_close()), - None, - ); - let base_url = Url::parse("https://httpbin.org").unwrap(); - - let (response, encoded_body) = http_client - .send_request::<(), HttpBinAnything>(base_url, Method::GET, (), None, None) - .unwrap(); - - let response_body: HttpBinAnything = - deserialize_response_body(encoded_body.as_slice()).unwrap(); - - assert!(response.status_code().is_success()); - assert!(!response_body.url.is_empty()); - assert_eq!(response_body.method.as_str(), "GET"); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn post_with_body() { - #[derive(Serialize, Deserialize, Debug)] - struct HttpBinAnything { - pub data: String, - pub method: String, - } - - impl RestPath<()> for HttpBinAnything { - fn get_path(_: ()) -> Result { - Ok(format!("anything")) - } - } - - let http_client = HttpClient::new( - DefaultSend {}, - false, - Some(Duration::from_secs(3u64)), - Some(headers_connection_close()), - None, - ); - - let body_test = "this is a test body with special characters {::}/-".to_string(); - let base_url = Url::parse("https://httpbin.org").unwrap(); - - let (response, encoded_body) = http_client - .send_request::<(), HttpBinAnything>( - base_url, - Method::POST, - (), - None, - Some(body_test.clone()), - ) - .unwrap(); - - let response_body: HttpBinAnything = - deserialize_response_body(encoded_body.as_slice()).unwrap(); - - assert!(response.status_code().is_success()); - assert_eq!(response_body.method.as_str(), "POST"); - assert_eq!(response_body.data, body_test); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn get_coins_list_from_coin_gecko_works() { - // Data structure that matches with REST API JSON - #[derive(Serialize, Deserialize, Debug)] - struct CoinGeckoCoinsList { - id: String, - symbol: String, - name: String, - } - - impl RestPath<()> for Vec { - fn get_path(_: ()) -> Result { - Ok(format!("api/v3/coins/list")) - } - } - - let http_client = - HttpClient::new(DefaultSend {}, true, Some(Duration::from_secs(3u64)), None, None); - let base_url = Url::parse("https://api.coingecko.com").unwrap(); - - let (response, encoded_body) = http_client - .send_request::<(), Vec>(base_url, Method::GET, (), None, None) - .unwrap(); - - let coins_list: Vec = - deserialize_response_body(encoded_body.as_slice()).unwrap(); - - assert!(response.status_code().is_success()); - assert!(!coins_list.is_empty()); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn authenticated_get_works() { - #[derive(Serialize, Deserialize, Debug)] - struct HttpBinAnything { - pub method: String, - pub url: String, - } - - impl RestPath<()> for HttpBinAnything { - fn get_path(_: ()) -> Result { - Ok(format!("anything")) - } - } - let base_url = Url::parse("https://httpbin.org").unwrap(); - let root_certificate = HTTPBIN_ROOT_CERT.to_string(); - - let http_client = HttpClient::new( - SendWithCertificateVerification::new(vec![root_certificate]), - true, - Some(Duration::from_secs(3u64)), - Some(headers_connection_close()), - None, - ); - - let (response, encoded_body) = http_client - .send_request::<(), HttpBinAnything>(base_url, Method::GET, (), None, None) - .unwrap(); - - let response_body: HttpBinAnything = - deserialize_response_body(encoded_body.as_slice()).unwrap(); - - assert!(response.status_code().is_success()); - assert!(!response_body.url.is_empty()); - assert_eq!(response_body.method.as_str(), "GET"); - } - - #[test] - #[ignore = "depends on external web-service that proved to be unreliable for CI"] - fn authenticated_get_with_wrong_root_certificate_fails() { - #[derive(Serialize, Deserialize, Debug)] - struct HttpBinAnything { - pub method: String, - pub url: String, - } - - impl RestPath<()> for HttpBinAnything { - fn get_path(_: ()) -> Result { - Ok(format!("anything")) - } - } - - let base_url = Url::parse("https://httpbin.org").unwrap(); - let root_certificates = vec![ - COINGECKO_ROOT_CERTIFICATE_LETSENCRYPT.to_string(), - COINGECKO_ROOT_CERTIFICATE_BALTIMORE.to_string(), - ]; - - let http_client = HttpClient::new( - SendWithCertificateVerification::new(root_certificates), - true, - Some(Duration::from_secs(3u64)), - Some(headers_connection_close()), - None, - ); - - let result = - http_client.send_request::<(), HttpBinAnything>(base_url, Method::GET, (), None, None); - assert_matches!(result, Err(Error::HttpReqError(_))); - let msg = format!("error {:?}", result.err()); - assert!(msg.contains("UnknownIssuer")); - } - - fn headers_connection_close() -> Headers { - let mut headers = Headers::new(); - add_to_headers(&mut headers, CONNECTION, HeaderValue::from_str("close").unwrap()); - headers - } - - fn deserialize_response_body<'a, T>(encoded_body: &'a [u8]) -> Result - where - T: Deserialize<'a>, - { - serde_json::from_slice::<'a, T>(encoded_body).map_err(|err| { - Error::DeserializeParseError(err, String::from_utf8_lossy(encoded_body).to_string()) - }) - } -} diff --git a/tee-worker/bitacross/core/rest-client/src/lib.rs b/tee-worker/bitacross/core/rest-client/src/lib.rs deleted file mode 100644 index 249bdf1b8b..0000000000 --- a/tee-worker/bitacross/core/rest-client/src/lib.rs +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! REST API Client, supporting SSL/TLS - -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(test, feature(assert_matches))] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -#[macro_use] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use http_req_sgx as http_req; - pub use http_sgx as http; - pub use thiserror_sgx as thiserror; -} - -pub mod error; -pub mod http_client; -pub mod rest_client; - -#[cfg(test)] -pub mod mocks; - -use crate::error::Error; -use std::string::String; - -/// Type for URL query parameters. -/// -/// Slice of tuples in which the first field is parameter name and second is value. -/// These parameters are used with `get_with` and `post_with` functions. -/// -/// # Examples -/// The vector -/// ```ignore -/// vec![("param1", "1234"), ("param2", "abcd")] -/// ``` -/// would be parsed to **param1=1234¶m2=abcd** in the request URL. -pub type Query<'a> = [(&'a str, &'a str)]; - -/// Rest path builder trait for type. -/// -/// Provides implementation for `rest_path` function that builds -/// type (and REST endpoint) specific API path from given parameter(s). -/// The built REST path is appended to the base URL given to `RestClient`. -/// If `Err` is returned, it is propagated directly to API caller. -pub trait RestPath { - /// Construct type specific REST API path from given parameters - /// (e.g. "api/devices/1234"). - fn get_path(par: T) -> Result; -} - -/// REST HTTP GET trait -/// -/// Provides the GET verb for a REST API -pub trait RestGet { - /// Plain GET request - fn get(&mut self, params: U) -> Result - where - T: serde::de::DeserializeOwned + RestPath; - - /// GET request with query parameters. - fn get_with(&mut self, params: U, query: &Query<'_>) -> Result - where - T: serde::de::DeserializeOwned + RestPath; -} - -/// REST HTTP POST trait -/// -/// Provides the POST verb for a REST API -pub trait RestPost { - /// Plain POST request. - fn post(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath; - - /// Make POST request with query parameters. - fn post_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath; - - /// Make a POST request and capture returned body. - fn post_capture(&mut self, params: U, data: &T) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned; - - /// Make a POST request with query parameters and capture returned body. - fn post_capture_with( - &mut self, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned; -} - -/// REST HTTP PUT trait -/// -/// Provides the PUT verb for a REST API -pub trait RestPut { - /// PUT request. - fn put(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath; - - /// Make PUT request with query parameters. - fn put_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath; - - /// Make a PUT request and capture returned body. - fn put_capture(&mut self, params: U, data: &T) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned; - - /// Make a PUT request with query parameters and capture returned body. - fn put_capture_with( - &mut self, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned; -} - -/// REST HTTP PATCH trait -/// -/// Provides the PATCH verb for a REST API -pub trait RestPatch { - /// Make a PATCH request. - fn patch(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath; - - /// Make PATCH request with query parameters. - fn patch_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath; -} - -/// REST HTTP DELETE trait -/// -/// Provides the DELETE verb for a REST API -pub trait RestDelete { - /// Make a DELETE request. - fn delete(&mut self, params: U) -> Result<(), Error> - where - T: RestPath; - - /// Make a DELETE request with query and body. - fn delete_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath; -} diff --git a/tee-worker/bitacross/core/rest-client/src/mocks/http_client_mock.rs b/tee-worker/bitacross/core/rest-client/src/mocks/http_client_mock.rs deleted file mode 100644 index 454165ac39..0000000000 --- a/tee-worker/bitacross/core/rest-client/src/mocks/http_client_mock.rs +++ /dev/null @@ -1,144 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::Error, - http_client::{EncodedBody, SendHttpRequest}, - Query, RestPath, -}; -use http_req::{request::Method, response::Response}; -use serde::{Deserialize, Serialize}; -use url::Url; - -const DEFAULT_HEAD: &[u8; 102] = b"HTTP/1.1 200 OK\r\n\ - Date: Sat, 11 Jan 2003 02:44:04 GMT\r\n\ - Content-Type: text/html\r\n\ - Content-Length: 100\r\n\r\n"; - -/// Response body returned by the HTTP client mock, contains information passed in by caller -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] -pub struct ResponseBodyMock { - pub base_url: String, - pub method: String, - pub path: String, - pub request_body: Option, - pub query_parameters: Vec<(String, String)>, -} - -impl RestPath for ResponseBodyMock { - fn get_path(path: String) -> Result { - Ok(format!("{}", path)) - } -} - -/// HTTP client mock - to be used in unit tests -pub struct HttpClientMock { - response: Option, -} - -impl HttpClientMock { - pub fn new(response: Option) -> Self { - HttpClientMock { response } - } -} - -impl SendHttpRequest for HttpClientMock { - fn send_request( - &self, - base_url: Url, - method: Method, - params: U, - query: Option<&Query<'_>>, - maybe_body: Option, - ) -> Result<(Response, EncodedBody), Error> - where - T: RestPath, - { - let path = T::get_path(params)?; - let response = self - .response - .clone() - .unwrap_or_else(|| Response::from_head(DEFAULT_HEAD).unwrap()); - let base_url_str = String::from(base_url.as_str()); - - let query_parameters = query - .map(|q| q.iter().map(|(key, value)| (key.to_string(), value.to_string())).collect()) - .unwrap_or_else(|| Vec::<(String, String)>::new()); - - let response_body = ResponseBodyMock { - base_url: base_url_str, - method: format!("{:?}", method), - path, - request_body: maybe_body, - query_parameters, - }; - - let encoded_response_body = serde_json::to_vec(&response_body).unwrap(); - - Ok((response, encoded_response_body)) - } -} - -#[cfg(test)] -mod tests { - - use super::*; - - #[test] - pub fn response_body_mock_serialization_works() { - let response_body_mock = ResponseBodyMock { - base_url: "https://mydomain.com".to_string(), - method: "GET".to_string(), - path: "/api/v1".to_string(), - request_body: None, - query_parameters: vec![("order".to_string(), "desc".to_string())], - }; - - let serialized_body = serde_json::to_string(&response_body_mock).unwrap(); - let deserialized_body: ResponseBodyMock = - serde_json::from_str(serialized_body.as_str()).unwrap(); - - assert_eq!(deserialized_body, response_body_mock); - } - - #[test] - pub fn default_head_is_valid() { - assert!(Response::from_head(DEFAULT_HEAD).is_ok()); - } - - #[test] - pub fn client_mock_returns_parameters_in_result() { - let client_mock = HttpClientMock::new(None); - let base_url = Url::parse("https://integritee.network").unwrap(); - - let (response, encoded_response_body) = client_mock - .send_request::( - base_url, - Method::GET, - "/api/v1/get".to_string(), - None, - None, - ) - .unwrap(); - - let response_body: ResponseBodyMock = - serde_json::from_slice(encoded_response_body.as_slice()).unwrap(); - - assert_eq!(response, Response::from_head(DEFAULT_HEAD).unwrap()); - assert_eq!(response_body.method.as_str(), "GET"); - } -} diff --git a/tee-worker/bitacross/core/rest-client/src/rest_client.rs b/tee-worker/bitacross/core/rest-client/src/rest_client.rs deleted file mode 100644 index 187553abc6..0000000000 --- a/tee-worker/bitacross/core/rest-client/src/rest_client.rs +++ /dev/null @@ -1,354 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -pub use http_req::{request::Method, response::Headers}; -pub use url::Url; - -use crate::{ - error::Error, http_client::SendHttpRequest, Query, RestDelete, RestGet, RestPatch, RestPath, - RestPost, RestPut, -}; - -use log::*; -use std::string::{String, ToString}; - -/// REST client to make HTTP GET and POST requests. -pub struct RestClient { - http_client: H, - baseurl: Url, - response_headers: Headers, - body_wash_fn: fn(String) -> String, -} - -impl RestClient -where - H: SendHttpRequest, -{ - /// Construct new client with default configuration to make HTTP requests. - /// - /// Use `Builder` to configure the client. - pub fn new(http_client: H, baseurl: Url) -> Self { - RestClient { - http_client, - baseurl, - response_headers: Headers::new(), - body_wash_fn: std::convert::identity, - } - } - - /// Set a function that cleans the response body up before deserializing it. - pub fn set_body_wash_fn(&mut self, func: fn(String) -> String) { - self.body_wash_fn = func; - } - - /// Response headers captured from previous request - pub fn response_headers(&mut self) -> &Headers { - &self.response_headers - } - - fn post_or_put(&mut self, method: Method, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - let data = serde_json::to_string(data).map_err(Error::SerializeParseError)?; - - let _body = self.make_request::(method, params, None, Some(data))?; - Ok(()) - } - - fn post_or_put_with( - &mut self, - method: Method, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - let data = serde_json::to_string(data).map_err(Error::SerializeParseError)?; - - let _body = self.make_request::(method, params, Some(query), Some(data))?; - Ok(()) - } - - fn post_or_put_capture( - &mut self, - method: Method, - params: U, - data: &T, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - let data = serde_json::to_string(data).map_err(Error::SerializeParseError)?; - - let body = self.make_request::(method, params, None, Some(data))?; - serde_json::from_str(body.as_str()).map_err(|err| Error::DeserializeParseError(err, body)) - } - - fn post_or_put_capture_with( - &mut self, - method: Method, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - let data = serde_json::to_string(data).map_err(Error::SerializeParseError)?; - - let body = self.make_request::(method, params, Some(query), Some(data))?; - serde_json::from_str(body.as_str()).map_err(|err| Error::DeserializeParseError(err, body)) - } - - fn make_request( - &mut self, - method: Method, - params: U, - query: Option<&Query<'_>>, - maybe_body: Option, - ) -> Result - where - T: RestPath, - { - let (response, encoded_body) = self.http_client.send_request::( - self.baseurl.clone(), - method, - params, - query, - maybe_body, - )?; - - self.response_headers = response.headers().clone(); - let status_code = response.status_code(); - - if !status_code.is_success() { - let status_code_num = u16::from(status_code); - let reason = String::from(status_code.reason().unwrap_or("none")); - return Err(Error::HttpError(status_code_num, reason)) - } - - let body = String::from_utf8_lossy(&encoded_body).to_string(); - - trace!("response headers: {:?}", self.response_headers); - trace!("response body: {}", body); - Ok((self.body_wash_fn)(body)) - } -} - -impl RestGet for RestClient -where - H: SendHttpRequest, -{ - /// Make a GET request. - fn get(&mut self, params: U) -> Result - where - T: serde::de::DeserializeOwned + RestPath, - { - let body = self.make_request::(Method::GET, params, None, None)?; - - serde_json::from_str(body.as_str()).map_err(|err| Error::DeserializeParseError(err, body)) - } - - /// Make a GET request with query parameters. - fn get_with(&mut self, params: U, query: &Query<'_>) -> Result - where - T: serde::de::DeserializeOwned + RestPath, - { - let body = self.make_request::(Method::GET, params, Some(query), None)?; - - serde_json::from_str(body.as_str()).map_err(|err| Error::DeserializeParseError(err, body)) - } -} - -impl RestPost for RestClient -where - H: SendHttpRequest, -{ - /// Make a POST request. - fn post(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put(Method::POST, params, data) - } - - /// Make POST request with query parameters. - fn post_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put_with(Method::POST, params, data, query) - } - - /// Make a POST request and capture returned body. - fn post_capture(&mut self, params: U, data: &T) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - self.post_or_put_capture(Method::POST, params, data) - } - - /// Make a POST request with query parameters and capture returned body. - fn post_capture_with( - &mut self, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - self.post_or_put_capture_with(Method::POST, params, data, query) - } -} - -impl RestPut for RestClient -where - H: SendHttpRequest, -{ - /// Make a PUT request. - fn put(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put(Method::PUT, params, data) - } - - /// Make PUT request with query parameters. - fn put_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put_with(Method::PUT, params, data, query) - } - - /// Make a PUT request and capture returned body. - fn put_capture(&mut self, params: U, data: &T) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - self.post_or_put_capture(Method::PUT, params, data) - } - - /// Make a PUT request with query parameters and capture returned body. - fn put_capture_with( - &mut self, - params: U, - data: &T, - query: &Query<'_>, - ) -> Result - where - T: serde::Serialize + RestPath, - K: serde::de::DeserializeOwned, - { - self.post_or_put_capture_with(Method::PUT, params, data, query) - } -} - -impl RestPatch for RestClient -where - H: SendHttpRequest, -{ - /// Make a PATCH request. - fn patch(&mut self, params: U, data: &T) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put(Method::PATCH, params, data) - } - - /// Make PATCH request with query parameters. - fn patch_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - self.post_or_put_with(Method::PATCH, params, data, query) - } -} - -impl RestDelete for RestClient -where - H: SendHttpRequest, -{ - /// Make a DELETE request. - fn delete(&mut self, params: U) -> Result<(), Error> - where - T: RestPath, - { - self.make_request::(Method::DELETE, params, None, None)?; - Ok(()) - } - - /// Make a DELETE request with query and body. - fn delete_with(&mut self, params: U, data: &T, query: &Query<'_>) -> Result<(), Error> - where - T: serde::Serialize + RestPath, - { - let data = serde_json::to_string(data).map_err(Error::SerializeParseError)?; - self.make_request::(Method::DELETE, params, Some(query), Some(data))?; - Ok(()) - } -} - -#[cfg(test)] -mod tests { - - use super::*; - use crate::mocks::http_client_mock::{HttpClientMock, ResponseBodyMock}; - - #[test] - pub fn get_sends_proper_request() { - let mut rest_client = create_default_rest_client(); - - let get_response = - rest_client.get::("/api/v2/get".to_string()).unwrap(); - - assert_eq!(get_response.method.as_str(), "GET"); - assert_eq!(get_response.path.as_str(), "/api/v2/get"); - } - - #[test] - pub fn get_with_query_parameters_works() { - let mut rest_client = create_default_rest_client(); - - let get_response = rest_client - .get_with::( - "/api/v1/get".to_string(), - &[("order", "desc"), ("user", "spongebob")], - ) - .unwrap(); - - assert_eq!(2, get_response.query_parameters.len()); - } - - fn create_default_rest_client() -> RestClient { - let base_url = Url::parse("https://example.com").unwrap(); - let http_client = HttpClientMock::new(None); - RestClient::new(http_client, base_url) - } -} diff --git a/tee-worker/bitacross/core/rpc-client/Cargo.toml b/tee-worker/bitacross/core/rpc-client/Cargo.toml deleted file mode 100644 index 01bb362a5c..0000000000 --- a/tee-worker/bitacross/core/rpc-client/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "itc-rpc-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -base58 = "0.2" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -log = "0.4" -openssl = { version = "0.10" } -parking_lot = "0.12.1" -serde_json = "1.0" -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -thiserror = { version = "1.0" } -url = { version = "2.0.0" } -ws = { version = "0.9.1", features = ["ssl"] } - -# parity -frame-metadata = { version = "15.1.0", features = ["v14"] } - -# local -itp-api-client-types = { path = "../../core-primitives/node-api/api-client-types" } -itp-rpc = { path = "../../core-primitives/rpc" } -itp-types = { path = "../../core-primitives/types" } -itp-utils = { path = "../../core-primitives/utils" } - -# litentry -ita-stf = { path = "../../app-libs/stf" } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives" } - -[dev-dependencies] -env_logger = "0.9.0" -itc-tls-websocket-server = { path = "../tls-websocket-server", features = ["mocks"] } -itp-networking-utils = { path = "../../core-primitives/networking-utils" } -rustls = { version = "0.19", features = ["dangerous_configuration"] } diff --git a/tee-worker/bitacross/core/rpc-client/src/mock.rs b/tee-worker/bitacross/core/rpc-client/src/mock.rs deleted file mode 100644 index 401c9496d2..0000000000 --- a/tee-worker/bitacross/core/rpc-client/src/mock.rs +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Interface for direct access to a workers rpc. - -use crate::{direct_client::DirectApi, error::Result}; -use codec::Decode; -use frame_metadata::RuntimeMetadataPrefixed; -use itp_api_client_types::Metadata; -use itp_stf_primitives::types::{AccountId, ShardIdentifier}; -use itp_types::MrEnclave; -use sgx_crypto_helper::rsa3072::Rsa3072PubKey; -use std::{sync::mpsc::Sender as MpscSender, thread::JoinHandle}; - -#[derive(Clone, Default)] -pub struct DirectClientMock { - rsa_pubkey: Rsa3072PubKey, - mu_ra_url: String, - untrusted_worker_url: String, - metadata: String, - nonce: u32, -} - -impl DirectClientMock { - pub fn new( - rsa_pubkey: Rsa3072PubKey, - mu_ra_url: String, - untrusted_worker_url: String, - metadata: String, - nonce: u32, - ) -> Self { - Self { rsa_pubkey, mu_ra_url, untrusted_worker_url, metadata, nonce } - } - - pub fn with_rsa_pubkey(mut self, key: Rsa3072PubKey) -> Self { - self.rsa_pubkey = key; - self - } - - pub fn with_mu_ra_url(mut self, url: &str) -> Self { - self.mu_ra_url = url.to_string(); - self - } - - pub fn with_untrusted_worker_url(mut self, url: &str) -> Self { - self.untrusted_worker_url = url.to_string(); - self - } - - pub fn with_metadata(mut self, metadata: String) -> Self { - self.metadata = metadata; - self - } - - pub fn with_nonce(mut self, nonce: u32) -> Self { - self.nonce = nonce; - self - } -} - -impl DirectApi for DirectClientMock { - fn get(&self, _request: &str) -> Result { - Ok("Hello_world".to_string()) - } - - fn watch(&self, _request: String, _sender: MpscSender) -> JoinHandle<()> { - unimplemented!() - } - - fn get_rsa_pubkey(&self) -> Result { - Ok(self.rsa_pubkey) - } - - fn get_mu_ra_url(&self) -> Result { - Ok(self.mu_ra_url.clone()) - } - - fn get_untrusted_worker_url(&self) -> Result { - Ok(self.untrusted_worker_url.clone()) - } - - fn get_state_metadata(&self) -> Result { - let metadata = RuntimeMetadataPrefixed::decode(&mut self.metadata.as_bytes())?; - Metadata::try_from(metadata).map_err(|e| e.into()) - } - - fn send(&self, _request: &str) -> Result<()> { - unimplemented!() - } - - fn close(&self) -> Result<()> { - unimplemented!() - } - - fn get_state_metadata_raw(&self) -> Result { - unimplemented!() - } - - fn get_next_nonce(&self, _shard: &ShardIdentifier, _account: &AccountId) -> Result { - Ok(self.nonce) - } - - fn get_state_mrenclave(&self) -> Result { - unimplemented!() - } -} diff --git a/tee-worker/bitacross/core/tls-websocket-server/Cargo.toml b/tee-worker/bitacross/core/tls-websocket-server/Cargo.toml deleted file mode 100644 index 3d50a3d177..0000000000 --- a/tee-worker/bitacross/core/tls-websocket-server/Cargo.toml +++ /dev/null @@ -1,70 +0,0 @@ -[package] -name = "itc-tls-websocket-server" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -bit-vec = { version = "0.6", default-features = false } -chrono = { version = "0.4.19", default-features = false, features = ["alloc"] } -rcgen = { package = "rcgen", default-features = false, git = "https://github.com/integritee-network/rcgen" } - -# sgx dependencies -sgx_tstd = { optional = true, features = ["net", "thread"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } - -# sgx enabled external libraries -mio-extras = { optional = true, default-features = false, git = "https://github.com/integritee-network/mio-extras-sgx", rev = "963234b" } -mio_sgx = { package = "mio", optional = true, git = "https://github.com/mesalock-linux/mio-sgx", tag = "sgx_1.1.3" } -rustls_sgx = { package = "rustls", optional = true, git = "https://github.com/mesalock-linux/rustls", branch = "mesalock_sgx" } -thiserror_sgx = { package = "thiserror", optional = true, git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } -tungstenite_sgx = { package = "tungstenite", optional = true, features = ["rustls-tls-webpki-roots"], git = "https://github.com/integritee-network/tungstenite-rs-sgx", branch = "sgx-experimental" } -webpki_sgx = { package = "webpki", optional = true, git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } -yasna_sgx = { package = "yasna", optional = true, default-features = false, features = ["bit-vec", "num-bigint", "chrono", "mesalock_sgx"], git = "https://github.com/mesalock-linux/yasna.rs-sgx", rev = "sgx_1.1.3" } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -mio = { version = "0.6.14", optional = true } -rustls = { version = "0.19", optional = true } -thiserror = { version = "1.0", optional = true } -tungstenite = { version = "0.15.0", optional = true, features = ["rustls-tls-webpki-roots"] } -webpki = { version = "0.21", optional = true } -yasna = { version = "0.4", optional = true, features = ["bit-vec", "num-bigint", "chrono", "std"] } - -# Substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# no-std compatible libraries -log = { version = "0.4", default-features = false } - -[dev-dependencies] -env_logger = "0.9.0" -rustls = { version = "0.19", features = ["dangerous_configuration"] } -url = { version = "2.0.0" } - - -[features] -default = ["std"] -sgx = [ - "mio-extras/sgx", - "mio_sgx", - "rcgen/sgx", - "rcgen/pem_sgx", - "rustls_sgx", - "sgx_tstd", - "thiserror_sgx", - "tungstenite_sgx", - "webpki_sgx", - "yasna_sgx", -] -std = [ - "mio", - "mio-extras/std", - "rcgen/std", - "rcgen/pem", - "rustls", - "thiserror", - "tungstenite", - "webpki", - "yasna", - "log/std", -] -mocks = [] diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/connection.rs b/tee-worker/bitacross/core/tls-websocket-server/src/connection.rs deleted file mode 100644 index 8704afe819..0000000000 --- a/tee-worker/bitacross/core/tls-websocket-server/src/connection.rs +++ /dev/null @@ -1,392 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; -use crate::{ - error::WebSocketError, - stream_state::{MaybeServerTlsStream, StreamState}, - ws_server::{ConnectionEvent, ConnectionEvents}, - WebSocketConnection, WebSocketMessageHandler, WebSocketResult, -}; -use log::*; -use mio::{event::Event, net::TcpStream, Poll, Ready, Token}; -use rustls::{ServerSession, Session}; -use std::{ - format, - io::ErrorKind, - string::{String, ToString}, - sync::{mpsc::Sender, Arc}, - time::Instant, - vec::Vec, -}; -use tungstenite::Message; - -/// A web-socket connection object. -pub struct TungsteniteWsConnection { - stream_state: StreamState, - connection_token: Token, - connection_handler: Arc, - is_closed: bool, -} - -impl TungsteniteWsConnection -where - Handler: WebSocketMessageHandler, -{ - pub fn new( - tcp_stream: TcpStream, - maybe_server_session: Option, - connection_token: Token, - handler: Arc, - ) -> WebSocketResult { - let stream_state = match maybe_server_session { - Some(sess) => StreamState::new_rustls_stream(sess, tcp_stream), - None => StreamState::new_plain_stream(tcp_stream), - }; - Ok(TungsteniteWsConnection { - stream_state, - connection_token, - connection_handler: handler, - is_closed: false, - }) - } - - fn maybe_do_tls_read(&mut self) -> ConnectionState { - match self.stream_state.internal_stream_mut() { - None => ConnectionState::Closing, - Some(MaybeServerTlsStream::Plain(_)) => ConnectionState::Alive, // noop for non-TLS ws server - Some(MaybeServerTlsStream::Rustls(s)) => { - let tls_session = &mut s.sess; - match tls_session.read_tls(&mut s.sock) { - Ok(r) => - if r == 0 { - return ConnectionState::Closing - }, - Err(err) => { - if let std::io::ErrorKind::WouldBlock = err.kind() { - debug!( - "TLS session is blocked (connection {})", - self.connection_token.0 - ); - return ConnectionState::Blocked - } - warn!( - "I/O error after reading TLS data (connection {}): {:?}", - self.connection_token.0, err - ); - return ConnectionState::Closing - }, - } - - match tls_session.process_new_packets() { - Ok(_) => { - if tls_session.is_handshaking() { - trace!("TLS session is in handshake"); - return ConnectionState::TlsHandshake - } - ConnectionState::Alive - }, - Err(e) => { - error!("cannot process TLS packet(s), closing connection: {:?}", e); - ConnectionState::Closing - }, - } - }, - } - } - - fn maybe_do_tls_write(&mut self) -> ConnectionState { - match self.stream_state.internal_stream_mut() { - None => ConnectionState::Closing, - Some(MaybeServerTlsStream::Plain(_)) => ConnectionState::Alive, // noop for non-TLS ws server - Some(MaybeServerTlsStream::Rustls(s)) => match s.sess.write_tls(&mut s.sock) { - Ok(_) => { - trace!("TLS write successful, connection {} is alive", self.connection_token.0); - if s.sess.is_handshaking() { - return ConnectionState::TlsHandshake - } - ConnectionState::Alive - }, - Err(e) => { - error!("TLS write error (connection {}): {:?}", self.connection_token.0, e); - ConnectionState::Closing - }, - }, - } - } - - /// Read from a web-socket, or initiate handshake if websocket is not initialized yet. - /// - /// Returns a boolean 'connection should be closed'. - fn drain_message_or_initialize_websocket( - &mut self, - ) -> WebSocketResult<(Option, bool)> { - if let StreamState::Established(web_socket) = &mut self.stream_state { - trace!( - "Read is possible for connection {}: {}", - self.connection_token.0, - web_socket.can_read() - ); - - let mut messages = Vec::new(); - let mut is_closing = false; - - // Looping over 'read_message' is merely a workaround for the unexpected behavior of mio event triggering. - // Final solution will be applied in P-907. - loop { - match web_socket.read_message() { - Ok(m) => messages.push(ConnectionEvent::Message(m)), - Err(e) => { - match e { - tungstenite::Error::Io(e) - if matches!(e.kind(), ErrorKind::WouldBlock) => {}, // no message to read - _ => { - trace!( - "Failed to read message from web-socket (connection {}): {:?}", - self.connection_token.0, - e - ); - is_closing = true; - }, - } - break - }, - } - } - - // if let Err(e) = message_sender.send(ConnectionEvents { - // connection_token: self.connection_token, - // events: messages.into(), - // }) { - // error!("Failed to send messages (connection {}): {:?}", self.connection_token.0, e); - // } - - trace!("Read successful for connection {}", self.connection_token.0); - Ok(( - Some(ConnectionEvents { - connection_token: self.connection_token, - events: messages.into(), - }), - is_closing, - )) - } else { - trace!("Initialize connection {}", self.connection_token.0); - self.stream_state = std::mem::take(&mut self.stream_state).attempt_handshake(); - if self.stream_state.is_invalid() { - warn!("Web-socket connection ({:?}) failed, closing", self.connection_token); - return Ok((None, true)) - } - debug!("Initialized connection {} successfully", self.connection_token.0); - Ok((None, false)) - } - } - - pub fn handle_message(&mut self, message: Message) -> WebSocketResult<()> { - match message { - Message::Text(string_message) => { - trace!( - "Got Message::Text on web-socket (connection {}), calling handler..", - self.connection_token.0 - ); - let message_handled_timer = Instant::now(); - if let Some(reply) = self - .connection_handler - .handle_message(self.connection_token.into(), string_message)? - { - trace!( - "Handling message yielded a reply, sending it now to connection {}..", - self.connection_token.0 - ); - self.write_message(reply)?; - trace!("Reply sent successfully to connection {}", self.connection_token.0); - } - debug!( - "Handled web-socket message in {} ms", - message_handled_timer.elapsed().as_millis() - ); - }, - Message::Binary(_) => { - warn!("received binary message, don't have a handler for this format"); - }, - Message::Close(_) => { - debug!( - "Received close frame, driving web-socket connection {} to close", - self.connection_token.0 - ); - if let StreamState::Established(web_socket) = &mut self.stream_state { - // Send a close frame back and then flush the send queue. - if let Err(e) = web_socket.close(None) { - match e { - tungstenite::Error::ConnectionClosed - | tungstenite::Error::AlreadyClosed => {}, - _ => warn!( - "Failed to send close frame (connection {}): {:?}", - self.connection_token.0, e - ), - } - } - match web_socket.write_pending() { - Ok(_) => {}, - Err(e) => match e { - tungstenite::Error::ConnectionClosed - | tungstenite::Error::AlreadyClosed => {}, - _ => warn!("Failed to write pending frames after closing (connection {}): {:?}", self.connection_token.0, e), - }, - } - } - debug!("Successfully closed connection {}", self.connection_token.0); - }, - _ => {}, - } - Ok(()) - } - - pub(crate) fn write_message(&mut self, message: String) -> WebSocketResult<()> { - match &mut self.stream_state { - StreamState::Established(web_socket) => { - if !web_socket.can_write() { - return Err(WebSocketError::ConnectionClosed) - } - debug!("Write message to connection {}: {}", self.connection_token.0, message); - web_socket - .write_message(Message::Text(message)) - .map_err(|e| WebSocketError::SocketWriteError(format!("{:?}", e))) - }, - _ => - Err(WebSocketError::SocketWriteError("No active web-socket available".to_string())), - } - } -} - -impl WebSocketConnection for TungsteniteWsConnection -where - Handler: WebSocketMessageHandler, -{ - type Socket = TcpStream; - - fn socket(&self) -> Option<&Self::Socket> { - self.stream_state.internal_stream().map(|s| s.inner()) - } - - fn get_session_readiness(&self) -> Ready { - match self.stream_state.internal_stream() { - None => mio::Ready::empty(), - Some(s) => { - let wants_read = s.wants_read(); - let wants_write = s.wants_write(); - - if wants_read && wants_write { - mio::Ready::readable() | mio::Ready::writable() - } else if wants_write { - mio::Ready::writable() - } else { - mio::Ready::readable() - } - }, - } - } - - fn on_ready( - &mut self, - poll: &mut Poll, - event: &Event, - message_sender: &Sender, - ) -> WebSocketResult<()> { - let mut is_closing = false; - let mut connection_events = None; - - if event.readiness().is_readable() { - trace!("Connection ({:?}) is readable", self.token()); - - let connection_state = self.maybe_do_tls_read(); - - if connection_state.is_alive() { - (connection_events, is_closing) = self.drain_message_or_initialize_websocket()?; - } else { - is_closing = connection_state.is_closing(); - } - } - - if event.readiness().is_writable() { - trace!("Connection ({:?}) is writable", self.token()); - - let connection_state = self.maybe_do_tls_write(); - - if connection_state.is_alive() { - if let StreamState::Established(web_socket) = &mut self.stream_state { - trace!("Web-socket, write pending messages"); - if let Err(e) = web_socket.write_pending() { - match e { - tungstenite::Error::ConnectionClosed - | tungstenite::Error::AlreadyClosed => is_closing = true, - _ => error!("Failed to write pending web-socket messages: {:?}", e), - } - } - } - } else { - is_closing = connection_state.is_closing(); - } - } - - if is_closing { - debug!("Connection ({:?}) is closed", self.token()); - self.is_closed = true; - } else { - // Re-register with the poll. - self.reregister(poll)?; - } - - if let Some(mut events) = connection_events { - if self.is_closed { - events.add_event(ConnectionEvent::Close) - } - if let Err(e) = message_sender.send(events) { - error!("Failed to send messages (connection {}): {:?}", self.connection_token.0, e); - } - } - - Ok(()) - } - - fn is_closed(&self) -> bool { - self.is_closed - } - - fn token(&self) -> Token { - self.connection_token - } -} - -/// Internal connection state. -#[derive(Debug, Clone)] -enum ConnectionState { - Closing, - Blocked, - Alive, - TlsHandshake, -} - -impl ConnectionState { - pub(crate) fn is_alive(&self) -> bool { - matches!(self, ConnectionState::Alive) - } - - pub(crate) fn is_closing(&self) -> bool { - matches!(self, ConnectionState::Closing) - } -} diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/lib.rs b/tee-worker/bitacross/core/tls-websocket-server/src/lib.rs deleted file mode 100644 index 6102fd52d3..0000000000 --- a/tee-worker/bitacross/core/tls-websocket-server/src/lib.rs +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -extern crate alloc; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use mio_sgx as mio; - pub use rustls_sgx as rustls; - pub use thiserror_sgx as thiserror; - pub use tungstenite_sgx as tungstenite; - pub use webpki_sgx as webpki; - pub use yasna_sgx as yasna; -} - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{ - connection_id_generator::{ConnectionId, ConnectionIdGenerator}, - error::{WebSocketError, WebSocketResult}, - ws_server::ConnectionEvents, -}; -use mio::{event::Evented, Token}; -use std::{fmt::Debug, string::String, sync::mpsc::Sender}; - -pub mod certificate_generation; -pub mod config_provider; -mod connection; -pub mod connection_id_generator; -pub mod error; -mod stream_state; -mod tls_common; -pub mod ws_server; - -#[cfg(any(test, feature = "mocks"))] -pub mod test; - -/// Connection token alias. -#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)] -pub struct ConnectionToken(pub usize); - -impl From for Token { - fn from(c: ConnectionToken) -> Self { - Token(c.0) - } -} - -impl From for ConnectionToken { - fn from(t: Token) -> Self { - ConnectionToken(t.0) - } -} - -/// Handles a web-socket connection message. -pub trait WebSocketMessageHandler: Send + Sync { - fn handle_message( - &self, - connection_token: ConnectionToken, - message: String, - ) -> WebSocketResult>; -} - -/// Allows to send response messages to a specific connection. -pub trait WebSocketResponder: Send + Sync { - fn send_message( - &self, - connection_token: ConnectionToken, - message: String, - ) -> WebSocketResult<()>; -} - -/// Run a web-socket server with a given handler. -pub trait WebSocketServer { - type Connection; - - fn run(&self) -> WebSocketResult<()>; - - fn is_running(&self) -> WebSocketResult; - - fn shut_down(&self) -> WebSocketResult<()>; -} - -/// Abstraction of a web socket connection using mio. -pub(crate) trait WebSocketConnection: Send + Sync { - /// Socket type, typically a TCP stream. - type Socket: Evented; - - /// Get the underlying socket (TCP stream) - fn socket(&self) -> Option<&Self::Socket>; - - /// Query the underlying session for readiness (read/write). - fn get_session_readiness(&self) -> mio::Ready; - - /// Handles the ready event, the connection has work to do. - fn on_ready( - &mut self, - poll: &mut mio::Poll, - ev: &mio::event::Event, - message_sender: &Sender, - ) -> WebSocketResult<()>; - - /// True if connection was closed. - fn is_closed(&self) -> bool; - - /// Return the connection token (= ID) - fn token(&self) -> mio::Token; - - /// Register the connection with the mio poll. - fn register(&mut self, poll: &mio::Poll) -> WebSocketResult<()> { - match self.socket() { - Some(s) => { - poll.register( - s, - self.token(), - self.get_session_readiness(), - mio::PollOpt::level() | mio::PollOpt::oneshot(), - )?; - Ok(()) - }, - None => Err(WebSocketError::ConnectionClosed), - } - } - - /// Re-register the connection with the mio poll, after handling an event. - fn reregister(&mut self, poll: &mio::Poll) -> WebSocketResult<()> { - match self.socket() { - Some(s) => { - poll.reregister( - s, - self.token(), - self.get_session_readiness(), - mio::PollOpt::level() | mio::PollOpt::oneshot(), - )?; - - Ok(()) - }, - None => Err(WebSocketError::ConnectionClosed), - } - } - - fn deregister(&mut self, poll: &mio::Poll) -> WebSocketResult<()> { - match self.socket() { - Some(s) => { - poll.deregister(s)?; - Ok(()) - }, - None => Err(WebSocketError::ConnectionClosed), - } - } -} diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs b/tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs deleted file mode 100644 index 42cded6e4b..0000000000 --- a/tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::WebSocketResult, ws_server::ConnectionEvents, WebSocketConnection}; -use mio::{Event, Evented, Poll, PollOpt, Ready, Token}; -use std::{sync::mpsc::Sender, vec::Vec}; -use tungstenite::Message; - -/// Mock implementation of a web socket connection. -#[derive(PartialEq, Eq, Clone)] -pub(crate) struct WebSocketConnectionMock { - pub id: Token, - pub messages_to_read: Vec, - pub messages_written: Vec, - pub is_closed: bool, - socket: SocketMock, -} - -impl WebSocketConnectionMock { - #[allow(unused)] - pub fn new(id: Token) -> Self { - WebSocketConnectionMock { - id, - messages_to_read: Default::default(), - messages_written: Default::default(), - is_closed: false, - socket: SocketMock {}, - } - } - - #[allow(unused)] - pub fn with_messages_to_read(mut self, messages: Vec) -> Self { - self.messages_to_read = messages; - self - } -} - -impl WebSocketConnection for WebSocketConnectionMock { - type Socket = SocketMock; - - fn socket(&self) -> Option<&Self::Socket> { - Some(&self.socket) - } - - fn get_session_readiness(&self) -> Ready { - Ready::readable() - } - - fn on_ready( - &mut self, - _poll: &mut Poll, - _ev: &Event, - _sender: &Sender, - ) -> WebSocketResult<()> { - Ok(()) - } - - fn is_closed(&self) -> bool { - self.is_closed - } - - fn token(&self) -> Token { - self.id - } -} - -#[derive(PartialEq, Eq, Clone)] -pub(crate) struct SocketMock; - -impl Evented for SocketMock { - fn register( - &self, - _poll: &Poll, - _token: Token, - _interest: Ready, - _opts: PollOpt, - ) -> std::io::Result<()> { - Ok(()) - } - - fn reregister( - &self, - _poll: &Poll, - _token: Token, - _interest: Ready, - _opts: PollOpt, - ) -> std::io::Result<()> { - Ok(()) - } - - fn deregister(&self, _poll: &Poll) -> std::io::Result<()> { - Ok(()) - } -} diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/ws_server.rs b/tee-worker/bitacross/core/tls-websocket-server/src/ws_server.rs deleted file mode 100644 index 7d92454e3c..0000000000 --- a/tee-worker/bitacross/core/tls-websocket-server/src/ws_server.rs +++ /dev/null @@ -1,618 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -#[cfg(feature = "sgx")] -use std::sync::{SgxMutex as Mutex, SgxRwLock as RwLock}; - -#[cfg(feature = "std")] -use std::sync::{Mutex, RwLock}; - -use crate::{ - config_provider::ProvideServerConfig, - connection::TungsteniteWsConnection, - connection_id_generator::GenerateConnectionId, - error::{WebSocketError, WebSocketResult}, - ConnectionIdGenerator, ConnectionToken, WebSocketConnection, WebSocketMessageHandler, - WebSocketResponder, WebSocketServer, -}; -use log::*; -use mio::{ - event::{Event, Evented}, - net::TcpListener, - Poll, Token, -}; -use mio_extras::channel::{channel, Receiver, Sender}; -use net::SocketAddr; -use rustls::ServerConfig; -use std::{ - collections::{HashMap, VecDeque}, - format, net, - string::String, - sync::{ - mpsc::{channel as std_channel, Receiver as StdReceiver, Sender as StdSender}, - Arc, - }, - thread, - vec::Vec, -}; -use tungstenite::Message; - -// Default tokens for the server. -pub(crate) const NEW_CONNECTIONS_LISTENER: mio::Token = mio::Token(0); -pub(crate) const SERVER_SIGNAL_TOKEN: mio::Token = mio::Token(1); - -// represents events for single connection -pub struct ConnectionEvents { - pub connection_token: Token, - pub events: VecDeque, -} - -impl ConnectionEvents { - pub fn add_event(&mut self, event: ConnectionEvent) { - self.events.push_back(event); - } -} - -pub enum ConnectionEvent { - Message(Message), - Close, -} - -/// Websocket server implementation using the Tungstenite library. -pub struct TungsteniteWsServer { - ws_address: String, - maybe_config_provider: Option>, - connection_handler: Arc, - id_generator: ConnectionIdGenerator, - connections: Arc>>>, - is_running: RwLock, - signal_sender: Mutex>>, -} - -impl TungsteniteWsServer -where - ConfigProvider: ProvideServerConfig, - Handler: WebSocketMessageHandler + 'static, -{ - pub fn new( - ws_address: String, - maybe_config_provider: Option>, - connection_handler: Arc, - ) -> Self { - TungsteniteWsServer { - ws_address, - maybe_config_provider, - connection_handler, - id_generator: ConnectionIdGenerator::default(), - connections: Default::default(), - is_running: Default::default(), - signal_sender: Default::default(), - } - } - - fn accept_connection( - &self, - poll: &mut Poll, - tcp_listener: &TcpListener, - maybe_tls_config: Option>, - ) -> WebSocketResult<()> { - let (socket, addr) = tcp_listener.accept()?; - - debug!("Accepting new connection from {:?}", addr); - - let connection_id = self.id_generator.next_id()?; - let token = mio::Token(connection_id); - trace!("New connection has token {:?}", token); - - let mut web_socket_connection = TungsteniteWsConnection::new( - socket, - maybe_tls_config.map(|c| rustls::ServerSession::new(&c)), - token, - self.connection_handler.clone(), - )?; - - trace!("Web-socket connection created"); - web_socket_connection.register(poll)?; - - let mut connections_lock = - self.connections.write().map_err(|_| WebSocketError::LockPoisoning)?; - connections_lock.insert(token, web_socket_connection); - - debug!("Accepted connection, {} active connections", connections_lock.len()); - Ok(()) - } - - fn connection_event( - &self, - poll: &mut mio::Poll, - event: &Event, - message_sender: StdSender, - ) -> WebSocketResult<()> { - let token = event.token(); - - let mut connections_lock = - self.connections.write().map_err(|_| WebSocketError::LockPoisoning)?; - - if let Some(connection) = connections_lock.get_mut(&token) { - connection.on_ready(poll, event, &message_sender)?; - - if connection.is_closed() { - trace!("Connection {:?} is closed, deregistering", token); - connection.deregister(poll)?; - } - } - - Ok(()) - } - - /// Send a message response to a connection. - /// Make sure this is called inside the event loop, otherwise dead-locks are possible. - fn write_message_to_connection( - &self, - message: String, - connection_token: ConnectionToken, - ) -> WebSocketResult<()> { - let mut connections_lock = - self.connections.write().map_err(|_| WebSocketError::LockPoisoning)?; - let connection = connections_lock - .get_mut(&connection_token.into()) - .ok_or_else(|| WebSocketError::InvalidConnection(connection_token.0))?; - connection.write_message(message) - } - - fn handle_server_signal( - &self, - poll: &mut mio::Poll, - event: &Event, - signal_receiver: &mut Receiver, - ) -> WebSocketResult { - let signal = signal_receiver.try_recv()?; - let mut do_shutdown = false; - - match signal { - ServerSignal::ShutDown => { - do_shutdown = true; - }, - ServerSignal::SendResponse(message, connection_token) => { - if let Err(e) = self.write_message_to_connection(message, connection_token) { - error!("Failed to send web-socket response: {:?}", e); - } - }, - } - - signal_receiver.reregister( - poll, - event.token(), - mio::Ready::readable(), - mio::PollOpt::level(), - )?; - - Ok(do_shutdown) - } - - fn register_server_signal_sender(&self, sender: Sender) -> WebSocketResult<()> { - let mut sender_lock = - self.signal_sender.lock().map_err(|_| WebSocketError::LockPoisoning)?; - *sender_lock = Some(sender); - Ok(()) - } - - fn send_server_signal(&self, server_signal: ServerSignal) -> WebSocketResult<()> { - match self.signal_sender.lock().map_err(|_| WebSocketError::LockPoisoning)?.as_ref() { - None => { - warn!( - "Signal sender has not been initialized, cannot send web-socket server signal" - ); - }, - Some(signal_sender) => { - signal_sender - .send(server_signal) - .map_err(|e| WebSocketError::Other(format!("{:?}", e).into()))?; - }, - } - - Ok(()) - } - - fn run_message_handling_thread(&self, events_receiver: StdReceiver) { - let connections = self.connections.clone(); - - thread::spawn(move || { - let mut events: Vec = Vec::new(); - let batch_size = 5u8; - - while let Ok(connection_events) = events_receiver.recv() { - events.push(connection_events); - - while !events.is_empty() { - for connection_events in events.iter_mut() { - let mut connections_lock = connections.write().unwrap(); - if let Some(connection) = - connections_lock.get_mut(&connection_events.connection_token) - { - // take turns to handle messages from different connection - for _ in 0..batch_size { - if let Some(event) = connection_events.events.pop_front() { - match event { - ConnectionEvent::Message(message) => { - if let Err(e) = connection.handle_message(message) { - error!( - "Failed to handle web-socket message (connection {}): {:?}", - connection_events.connection_token.0, e - ); - }; - }, - ConnectionEvent::Close => { - //close connection - }, - } - } else { - break - } - } - } else { - // drop messages if connection not exist - connection_events.events.clear(); - error!( - "Failed to handle web-socket message (connection {}): connection closed", connection_events.connection_token.0 - ); - } - } - - // try recv new messages - while let Ok(connection_events) = events_receiver.try_recv() { - if let Some(events) = events - .iter_mut() - .find(|ev| ev.connection_token == connection_events.connection_token) - { - events.events.extend(connection_events.events); - } else { - events.push(connection_events); - } - } - - // remove empty VecDeque - events.retain(|ev| !ev.events.is_empty()); - } - } - }); - } -} - -impl WebSocketServer for TungsteniteWsServer -where - ConfigProvider: ProvideServerConfig, - Handler: WebSocketMessageHandler + 'static, -{ - type Connection = TungsteniteWsConnection; - - fn run(&self) -> WebSocketResult<()> { - info!("Running tungstenite web socket server on {}", self.ws_address); - - let socket_addr: SocketAddr = - self.ws_address.parse().map_err(WebSocketError::InvalidWsAddress)?; - - let maybe_config = match &self.maybe_config_provider { - Some(p) => Some(p.get_config()?), - None => None, - }; - - let (server_signal_sender, mut signal_receiver) = channel::(); - self.register_server_signal_sender(server_signal_sender)?; - - let tcp_listener = net::TcpListener::bind(socket_addr).expect("Could not listen on port"); - let tcp_listener = - mio::net::TcpListener::from_std(tcp_listener).map_err(WebSocketError::TcpBindError)?; - let mut poll = Poll::new()?; - poll.register( - &tcp_listener, - NEW_CONNECTIONS_LISTENER, - mio::Ready::readable(), - mio::PollOpt::level(), - )?; - - poll.register( - &signal_receiver, - SERVER_SIGNAL_TOKEN, - mio::Ready::readable(), - mio::PollOpt::level(), - )?; - - let mut events = mio::Events::with_capacity(2048); - - *self.is_running.write().map_err(|_| WebSocketError::LockPoisoning)? = true; - - // Run message handling thread - let (message_sender, message_receiver) = std_channel(); - self.run_message_handling_thread(message_receiver); - - // Run the event loop. - 'outer_event_loop: loop { - let num_events = poll.poll(&mut events, None)?; - debug!("Number of readiness events: {}", num_events); - - for event in events.iter() { - match event.token() { - NEW_CONNECTIONS_LISTENER => { - trace!("Received new connection event"); - if let Err(e) = - self.accept_connection(&mut poll, &tcp_listener, maybe_config.clone()) - { - error!("Failed to accept new web-socket connection: {:?}", e); - } - }, - SERVER_SIGNAL_TOKEN => { - trace!("Received server signal event"); - if self.handle_server_signal(&mut poll, &event, &mut signal_receiver)? { - break 'outer_event_loop - } - }, - _ => { - trace!("Connection (token {:?}) activity event", event.token()); - if let Err(e) = - self.connection_event(&mut poll, &event, message_sender.clone()) - { - error!("Failed to process connection event: {:?}", e); - } - }, - } - } - } - - info!("Web-socket server has shut down"); - Ok(()) - } - - fn is_running(&self) -> WebSocketResult { - Ok(*self.is_running.read().map_err(|_| WebSocketError::LockPoisoning)?) - } - - fn shut_down(&self) -> WebSocketResult<()> { - info!("Shutdown request of web-socket server detected, shutting down.."); - self.send_server_signal(ServerSignal::ShutDown) - } -} - -impl WebSocketResponder for TungsteniteWsServer -where - ConfigProvider: ProvideServerConfig, - Handler: WebSocketMessageHandler + 'static, -{ - fn send_message( - &self, - connection_token: ConnectionToken, - message: String, - ) -> WebSocketResult<()> { - self.send_server_signal(ServerSignal::SendResponse(message, connection_token)) - } -} - -/// Internal server signal enum. -enum ServerSignal { - ShutDown, - SendResponse(String, ConnectionToken), -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test::{ - fixtures::{no_cert_verifier::NoCertVerifier, test_server::create_server}, - mocks::web_socket_handler_mock::WebSocketHandlerMock, - }; - use rustls::ClientConfig; - use std::{net::TcpStream, thread, time::Duration}; - use tungstenite::{ - client_tls_with_config, stream::MaybeTlsStream, Connector, Message, WebSocket, - }; - use url::Url; - - #[test] - fn server_handles_multiple_connections() { - let _ = env_logger::builder().is_test(true).try_init(); - - let expected_answer = "websocket server response bidibibup".to_string(); - let port: u16 = 21777; - const NUMBER_OF_CONNECTIONS: usize = 100; - - let (server, handler) = create_server(vec![expected_answer.clone()], port); - - let server_clone = server.clone(); - let server_join_handle = thread::spawn(move || server_clone.run()); - - // Wait until server is up. - while !server.is_running().unwrap() { - thread::sleep(std::time::Duration::from_millis(50)); - } - - // Spawn multiple clients that connect to the server simultaneously and send a message. - let client_handles: Vec<_> = (0..NUMBER_OF_CONNECTIONS) - .map(|_| { - let expected_answer_clone = expected_answer.clone(); - - thread::sleep(Duration::from_millis(5)); - - thread::spawn(move || { - let mut socket = connect_tls_client(get_server_addr(port).as_str()); - - socket - .write_message(Message::Text("Hello WebSocket".into())) - .expect("client write message to be successful"); - - assert_eq!( - Message::Text(expected_answer_clone), - socket.read_message().unwrap() - ); - - thread::sleep(Duration::from_millis(2)); - - socket - .write_message(Message::Text("Second message".into())) - .expect("client write message to be successful"); - - thread::sleep(Duration::from_millis(2)); - - socket.close(None).unwrap(); - socket.write_pending().unwrap(); - }) - }) - .collect(); - - for handle in client_handles.into_iter() { - handle.join().expect("client handle to be joined"); - } - - server.shut_down().unwrap(); - - let server_shutdown_result = - server_join_handle.join().expect("Couldn't join on the associated thread"); - if let Err(e) = server_shutdown_result { - panic!("Test failed, web-socket returned error: {:?}", e); - } - - assert_eq!(2 * NUMBER_OF_CONNECTIONS, handler.get_handled_messages().len()); - } - - #[test] - fn server_closes_connection_if_client_does_not_wait_for_reply() { - let _ = env_logger::builder().is_test(true).try_init(); - - let expected_answer = "websocket server response".to_string(); - let port: u16 = 21778; - - let (server, handler) = create_server(vec![expected_answer.clone()], port); - - let server_clone = server.clone(); - let server_join_handle = thread::spawn(move || server_clone.run()); - - // Wait until server is up. - while !server.is_running().unwrap() { - thread::sleep(std::time::Duration::from_millis(50)); - } - - let client_join_handle = thread::spawn(move || { - let mut socket = connect_tls_client(get_server_addr(port).as_str()); - socket - .write_message(Message::Text("First request".into())) - .expect("client write message to be successful"); - - // We never read, just send a message and close the connection, despite the server - // trying to send a reply (which will fail). - socket.close(None).unwrap(); - socket.write_pending().unwrap(); - }); - - client_join_handle.join().unwrap(); - server.shut_down().unwrap(); - server_join_handle.join().unwrap().unwrap(); - - assert_eq!(1, handler.get_handled_messages().len()); - } - - #[test] - fn server_sends_update_message_to_client() { - let _ = env_logger::builder().is_test(true).try_init(); - - let expected_answer = "first response".to_string(); - let port: u16 = 21779; - let (server, handler) = create_server(vec![expected_answer.clone()], port); - - let server_clone = server.clone(); - let server_join_handle = thread::spawn(move || server_clone.run()); - - // Wait until server is up. - while !server.is_running().unwrap() { - thread::sleep(std::time::Duration::from_millis(50)); - } - - let update_message = "Message update".to_string(); - let update_message_clone = update_message.clone(); - - let client_join_handle = thread::spawn(move || { - let mut socket = connect_tls_client(get_server_addr(port).as_str()); - socket - .write_message(Message::Text("First request".into())) - .expect("client write message to be successful"); - - assert_eq!(Message::Text(expected_answer), socket.read_message().unwrap()); - assert_eq!(Message::Text(update_message_clone), socket.read_message().unwrap()); - }); - - let connection_token = poll_handler_for_first_connection(handler.as_ref()); - - // Send reply to a wrong connection token. Succeeds, because error is caught in the event loop - // and not the `send_message` method itself. - assert!(server - .send_message( - ConnectionToken(connection_token.0 + 1), - "wont get to the client".to_string() - ) - .is_ok()); - - // Send reply to the correct connection token. - server.send_message(connection_token, update_message).unwrap(); - - client_join_handle.join().unwrap(); - server.shut_down().unwrap(); - server_join_handle.join().unwrap().unwrap(); - - assert_eq!(1, handler.get_handled_messages().len()); - } - - // Ignored because it does not directly test any of our own components. - // It was used to test the behavior of the tungstenite client configuration with certificates. - #[test] - #[ignore] - fn client_test() { - let mut socket = connect_tls_client("ws.ifelse.io:443"); - - socket - .write_message(Message::Text("Hello WebSocket".into())) - .expect("client write message to be successful"); - } - - fn poll_handler_for_first_connection(handler: &WebSocketHandlerMock) -> ConnectionToken { - loop { - match handler.get_handled_messages().first() { - None => thread::sleep(Duration::from_millis(5)), - Some(m) => return m.0, - } - } - } - - fn get_server_addr(port: u16) -> String { - format!("localhost:{}", port) - } - - fn connect_tls_client(server_addr: &str) -> WebSocket> { - let server_url = Url::parse(format!("wss://{}", server_addr).as_str()).unwrap(); - - let mut config = ClientConfig::new(); - config.dangerous().set_certificate_verifier(Arc::new(NoCertVerifier {})); - let connector = Connector::Rustls(Arc::new(config)); - let stream = TcpStream::connect(server_url.authority()).unwrap(); - - let (socket, _response) = - client_tls_with_config(server_url.as_str(), stream, None, Some(connector)) - .expect("Can't connect"); - - socket - } -} diff --git a/tee-worker/bitacross/enclave-runtime/Cargo.lock b/tee-worker/bitacross/enclave-runtime/Cargo.lock index 429c5aa835..0062a3972d 100644 --- a/tee-worker/bitacross/enclave-runtime/Cargo.lock +++ b/tee-worker/bitacross/enclave-runtime/Cargo.lock @@ -15,17 +15,17 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", - "log 0.4.17", + "log 0.4.21", "maybe-async", ] [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", "bitvec", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -268,6 +268,278 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bc-ita-parentchain-interface" +version = "0.1.0" +dependencies = [ + "bc-enclave-registry", + "bc-ita-sgx-runtime", + "bc-ita-stf", + "bc-itc-parentchain-indirect-calls-executor", + "bc-relayer-registry", + "bc-signer-registry", + "itp-api-client-types", + "itp-node-api", + "itp-stf-primitives", + "itp-types", + "litentry-primitives", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bc-ita-sgx-runtime" +version = "0.1.0" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "itp-sgx-runtime-primitives", + "pallet-balances", + "pallet-parentchain", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std", + "sp-version", +] + +[[package]] +name = "bc-ita-stf" +version = "0.1.0" +dependencies = [ + "bc-ita-sgx-runtime", + "frame-support", + "frame-system", + "hex", + "hex-literal", + "itp-hashing", + "itp-node-api", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-storage", + "itp-types", + "itp-utils", + "litentry-macros 0.1.0", + "litentry-primitives", + "log 0.4.21", + "pallet-balances", + "pallet-parentchain", + "pallet-sudo", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bc-itc-direct-rpc-client" +version = "0.1.0" +dependencies = [ + "itp-rpc", + "itp-types", + "itp-utils", + "log 0.4.21", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", + "serde_json 1.0.103", + "sgx_tstd", + "tungstenite", + "url 2.5.0", + "webpki", +] + +[[package]] +name = "bc-itc-direct-rpc-server" +version = "0.1.0" +dependencies = [ + "itc-tls-websocket-server", + "itp-rpc", + "itp-types", + "itp-utils", + "jsonrpc-core", + "log 0.4.21", + "parity-scale-codec", + "serde_json 1.0.103", + "sgx_tstd", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "bc-itc-offchain-worker-executor" +version = "0.1.0" +dependencies = [ + "bc-itp-stf-executor", + "bc-itp-top-pool-author", + "itc-parentchain-light-client", + "itp-extrinsics-factory", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-types", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "bc-itc-parentchain" +version = "0.1.0" +dependencies = [ + "bc-itc-parentchain-block-import-dispatcher", + "bc-itc-parentchain-block-importer", + "bc-itc-parentchain-indirect-calls-executor", + "itc-parentchain-light-client", + "itp-types", + "parity-scale-codec", + "sp-runtime", +] + +[[package]] +name = "bc-itc-parentchain-block-import-dispatcher" +version = "0.1.0" +dependencies = [ + "bc-itc-parentchain-block-importer", + "itp-import-queue", + "log 0.4.21", + "sgx_tstd", + "sgx_types", + "thiserror", +] + +[[package]] +name = "bc-itc-parentchain-block-importer" +version = "0.1.0" +dependencies = [ + "bc-ita-stf", + "bc-itc-parentchain-indirect-calls-executor", + "bc-itp-stf-executor", + "itc-parentchain-light-client", + "itp-enclave-metrics", + "itp-extrinsics-factory", + "itp-ocall-api", + "itp-stf-interface", + "itp-types", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "bc-itc-parentchain-indirect-calls-executor" +version = "0.1.0" +dependencies = [ + "bc-enclave-registry", + "bc-itp-stf-executor", + "bc-itp-top-pool-author", + "bc-relayer-registry", + "bc-signer-registry", + "binary-merkle-tree", + "bs58", + "futures 0.3.8", + "itp-api-client-types", + "itp-node-api", + "itp-sgx-crypto", + "itp-sgx-runtime-primitives", + "itp-stf-primitives", + "itp-test", + "itp-types", + "litentry-primitives", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "bc-itp-stf-executor" +version = "0.1.0" +dependencies = [ + "bc-itp-top-pool-author", + "hex", + "itc-parentchain-test", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-stf-state-observer", + "itp-test", + "itp-time-utils", + "itp-types", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-core", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "bc-itp-top-pool" +version = "0.1.0" +dependencies = [ + "bc-itc-direct-rpc-server", + "byteorder 1.4.3", + "derive_more", + "itp-stf-primitives", + "itp-types", + "jsonrpc-core", + "linked-hash-map", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "bc-itp-top-pool-author" +version = "0.1.0" +dependencies = [ + "bc-itp-top-pool", + "derive_more", + "itp-enclave-metrics", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "itp-utils", + "jsonrpc-core", + "lazy_static", + "litentry-primitives", + "log 0.4.21", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", +] + [[package]] name = "bc-musig2-ceremony" version = "0.1.0" @@ -287,9 +559,9 @@ name = "bc-musig2-event" version = "0.1.0" dependencies = [ "bc-enclave-registry", + "bc-itc-direct-rpc-client", + "bc-itc-direct-rpc-server", "bc-musig2-ceremony", - "itc-direct-rpc-client", - "itc-direct-rpc-server", "itp-ocall-api", "itp-rpc", "itp-sgx-crypto", @@ -312,7 +584,7 @@ dependencies = [ "itp-settings", "itp-sgx-io", "litentry-primitives", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_tstd", "sp-std", @@ -338,6 +610,10 @@ name = "bc-task-processor" version = "0.1.0" dependencies = [ "bc-enclave-registry", + "bc-ita-stf", + "bc-itc-direct-rpc-client", + "bc-itc-direct-rpc-server", + "bc-itp-stf-executor", "bc-musig2-ceremony", "bc-musig2-event", "bc-relayer-registry", @@ -345,18 +621,14 @@ dependencies = [ "bc-task-sender", "frame-support", "futures 0.3.8", - "ita-stf", - "itc-direct-rpc-client", - "itc-direct-rpc-server", "itp-enclave-metrics", "itp-ocall-api", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-state-handler", "lc-direct-call", "litentry-primitives", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_crypto_helper", "sgx_tstd", @@ -385,7 +657,7 @@ checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", ] @@ -540,7 +812,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" dependencies = [ - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", ] @@ -978,6 +1250,15 @@ name = "enclave-runtime" version = "0.0.1" dependencies = [ "bc-enclave-registry", + "bc-ita-parentchain-interface", + "bc-ita-sgx-runtime", + "bc-ita-stf", + "bc-itc-direct-rpc-server", + "bc-itc-offchain-worker-executor", + "bc-itc-parentchain", + "bc-itp-stf-executor", + "bc-itp-top-pool", + "bc-itp-top-pool-author", "bc-musig2-ceremony", "bc-relayer-registry", "bc-signer-registry", @@ -990,12 +1271,6 @@ dependencies = [ "futures 0.3.8", "hex", "ipfs-unixfs", - "ita-parentchain-interface", - "ita-sgx-runtime", - "ita-stf", - "itc-direct-rpc-server", - "itc-offchain-worker-executor", - "itc-parentchain", "itc-parentchain-light-client", "itc-parentchain-test", "itc-tls-websocket-server", @@ -1014,15 +1289,12 @@ dependencies = [ "itp-sgx-crypto", "itp-sgx-externalities", "itp-sgx-temp-dir", - "itp-stf-executor", "itp-stf-interface", "itp-stf-primitives", "itp-stf-state-handler", "itp-stf-state-observer", "itp-storage", "itp-test", - "itp-top-pool", - "itp-top-pool-author", "itp-types", "itp-utils", "jsonrpc-core", @@ -1040,11 +1312,11 @@ dependencies = [ "rust-base58", "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", + "sgx_crypto_helper", "sgx_rand", "sgx_serialize", "sgx_serialize_derive", "sgx_tcrypto", - "sgx_tcrypto_helper", "sgx_trts", "sgx_tse", "sgx_tseal", @@ -1144,7 +1416,7 @@ dependencies = [ "evm-core", "evm-gasometer", "evm-runtime", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "primitive-types", "rlp", @@ -1306,7 +1578,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -1334,7 +1606,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bitflags", "environmental 1.1.4", @@ -1342,7 +1614,7 @@ dependencies = [ "frame-support-procedural", "impl-trait-for-tuples", "k256", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "paste", "scale-info", @@ -1364,7 +1636,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "cfg-expr", @@ -1380,7 +1652,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1392,7 +1664,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -1402,10 +1674,10 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", "sp-core", @@ -1699,7 +1971,7 @@ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "hashbrown_tstd" version = "0.12.0" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "heck" @@ -1835,262 +2107,62 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote 1.0.36", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.6.1" -source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" -dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.9.1", - "sgx_tstd", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" -dependencies = [ - "sgx_libc", -] - -[[package]] -name = "ipfs-unixfs" -version = "0.0.1" -source = "git+https://github.com/whalelephant/rust-ipfs?branch=w-nstd#52f84dceea7065bb4ee2c24da53b3bedf162241a" -dependencies = [ - "cid", - "either", - "multihash", - "quick-protobuf", - "sha2 0.9.9", -] - -[[package]] -name = "ita-parentchain-interface" -version = "0.1.0" -dependencies = [ - "bc-enclave-registry", - "bc-relayer-registry", - "bc-signer-registry", - "ita-sgx-runtime", - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itp-api-client-types", - "itp-node-api", - "itp-stf-primitives", - "itp-types", - "litentry-primitives", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "ita-sgx-runtime" -version = "0.1.0" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "itp-sgx-runtime-primitives", - "pallet-balances", - "pallet-parentchain", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "ita-stf" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "hex", - "hex-literal", - "ita-sgx-runtime", - "itp-hashing", - "itp-node-api", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-storage", - "itp-types", - "itp-utils", - "litentry-macros 0.1.0", - "litentry-primitives", - "log 0.4.17", - "pallet-balances", - "pallet-parentchain", - "pallet-sudo", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "itc-direct-rpc-client" -version = "0.1.0" -dependencies = [ - "itp-rpc", - "log 0.4.21", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", - "serde_json 1.0.103", - "sgx_tstd", - "tungstenite", - "url 2.5.0", - "webpki", -] - -[[package]] -name = "itc-direct-rpc-server" -version = "0.1.0" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "itc-tls-websocket-server", - "itp-rpc", - "itp-types", - "itp-utils", - "jsonrpc-core", - "log 0.4.17", - "parity-scale-codec", - "serde_json 1.0.103", - "sgx_tstd", - "sp-runtime", - "thiserror", + "proc-macro2", + "quote 1.0.36", + "syn 1.0.109", ] [[package]] -name = "itc-offchain-worker-executor" -version = "0.1.0" +name = "indexmap" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" dependencies = [ - "itc-parentchain-light-client", - "itp-extrinsics-factory", - "itp-stf-executor", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-top-pool-author", - "itp-types", - "log 0.4.17", - "parity-scale-codec", + "autocfg 1.1.0", + "hashbrown 0.9.1", "sgx_tstd", - "sp-runtime", - "thiserror", ] [[package]] -name = "itc-parentchain" -version = "0.1.0" +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "itc-parentchain-block-import-dispatcher", - "itc-parentchain-block-importer", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-types", - "parity-scale-codec", - "sp-runtime", + "equivalent", + "hashbrown 0.14.0", ] [[package]] -name = "itc-parentchain-block-import-dispatcher" -version = "0.1.0" +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" dependencies = [ - "itc-parentchain-block-importer", - "itp-import-queue", - "log 0.4.17", - "sgx_tstd", - "sgx_types", - "thiserror", + "num-traits 0.2.16", ] [[package]] -name = "itc-parentchain-block-importer" -version = "0.1.0" +name = "iovec" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" dependencies = [ - "ita-stf", - "itc-parentchain-indirect-calls-executor", - "itc-parentchain-light-client", - "itp-enclave-metrics", - "itp-extrinsics-factory", - "itp-ocall-api", - "itp-stf-executor", - "itp-stf-interface", - "itp-types", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-runtime", - "thiserror", + "sgx_libc", ] [[package]] -name = "itc-parentchain-indirect-calls-executor" -version = "0.1.0" +name = "ipfs-unixfs" +version = "0.0.1" +source = "git+https://github.com/whalelephant/rust-ipfs?branch=w-nstd#52f84dceea7065bb4ee2c24da53b3bedf162241a" dependencies = [ - "bc-enclave-registry", - "bc-relayer-registry", - "bc-signer-registry", - "binary-merkle-tree", - "bs58", - "futures 0.3.8", - "itp-api-client-types", - "itp-node-api", - "itp-sgx-crypto", - "itp-sgx-runtime-primitives", - "itp-stf-executor", - "itp-stf-primitives", - "itp-test", - "itp-top-pool-author", - "itp-types", - "litentry-primitives", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-runtime", - "thiserror", + "cid", + "either", + "multihash", + "quick-protobuf", + "sha2 0.9.9", ] [[package]] @@ -2105,7 +2177,7 @@ dependencies = [ "itp-storage", "itp-test", "itp-types", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_tstd", "sgx_types", @@ -2128,11 +2200,11 @@ version = "0.1.0" dependencies = [ "bit-vec", "chrono 0.4.31", - "log 0.4.17", + "log 0.4.21", "mio", "mio-extras", "rcgen", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "sgx_tstd", "sp-core", "thiserror", @@ -2197,10 +2269,10 @@ dependencies = [ "itp-sgx-crypto", "itp-sgx-io", "itp-time-utils", - "log 0.4.17", + "log 0.4.21", "num-bigint", "parity-scale-codec", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_rand", "sgx_tcrypto", @@ -2226,6 +2298,7 @@ dependencies = [ name = "itp-enclave-metrics" version = "0.1.0" dependencies = [ + "litentry-primitives", "parity-scale-codec", "sgx_tstd", ] @@ -2237,7 +2310,7 @@ dependencies = [ "itp-node-api", "itp-nonce-cache", "itp-types", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_tstd", "sgx_types", @@ -2281,6 +2354,7 @@ dependencies = [ "itp-stf-primitives", "parity-scale-codec", "sp-core", + "sp-version", ] [[package]] @@ -2338,6 +2412,9 @@ dependencies = [ [[package]] name = "itp-settings" version = "0.1.0" +dependencies = [ + "litentry-primitives", +] [[package]] name = "itp-sgx-crypto" @@ -2349,10 +2426,10 @@ dependencies = [ "itp-sgx-io", "itp-sgx-temp-dir", "k256", - "log 0.4.17", + "log 0.4.21", "ofb", "parity-scale-codec", - "secp256k1 0.29.0", + "secp256k1 0.28.0", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_crypto_helper", "sgx_rand", @@ -2368,7 +2445,7 @@ dependencies = [ "derive_more", "environmental 1.1.3", "itp-hashing", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "postcard", "serde 1.0.204", @@ -2401,33 +2478,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "itp-stf-executor" -version = "0.1.0" -dependencies = [ - "hex", - "itc-parentchain-test", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-stf-state-observer", - "itp-test", - "itp-time-utils", - "itp-top-pool-author", - "itp-types", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "thiserror", -] - [[package]] name = "itp-stf-interface" version = "0.8.0" @@ -2466,7 +2516,7 @@ dependencies = [ "itp-stf-state-observer", "itp-time-utils", "itp-types", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "rust-base58", "sgx_tstd", @@ -2480,7 +2530,7 @@ name = "itp-stf-state-observer" version = "0.1.0" dependencies = [ "itp-types", - "log 0.4.17", + "log 0.4.21", "sgx_tstd", "thiserror", ] @@ -2521,7 +2571,7 @@ dependencies = [ "jsonrpc-core", "lc-teebag-storage", "litentry-primitives", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_crypto_helper", "sgx_tstd", @@ -2540,44 +2590,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "itp-top-pool" -version = "0.1.0" -dependencies = [ - "byteorder 1.4.3", - "derive_more", - "itc-direct-rpc-server", - "itp-stf-primitives", - "itp-types", - "jsonrpc-core", - "linked-hash-map", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "itp-top-pool-author" -version = "0.1.0" -dependencies = [ - "derive_more", - "itp-sgx-crypto", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool", - "itp-types", - "jsonrpc-core", - "lazy_static", - "log 0.4.17", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", -] - [[package]] name = "itp-types" version = "0.1.0" @@ -2591,6 +2603,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "serde 1.0.204", + "sp-consensus-grandpa", "sp-core", "sp-runtime", "sp-std", @@ -2773,8 +2786,8 @@ dependencies = [ "core-primitives", "hex", "itp-sgx-crypto", - "litentry-hex-utils 0.1.0", - "log 0.4.17", + "itp-sgx-runtime-primitives", + "log 0.4.21", "pallet-teebag", "parity-scale-codec", "rand 0.7.3", @@ -2907,7 +2920,7 @@ version = "2.0.6" source = "git+https://github.com/integritee-network/mio-extras-sgx?rev=963234b#963234bf55e44f9efff921938255126c48deef3a" dependencies = [ "lazycell", - "log 0.4.17", + "log 0.4.21", "mio", "sgx_tstd", "sgx_types", @@ -2941,7 +2954,7 @@ dependencies = [ [[package]] name = "musig2" version = "0.0.8" -source = "git+https://github.com/kailai-wang/musig2.git?branch=use-sha2-0.8#93857e52abbe8f9898c9ec743eecb1380132abcb" +source = "git+https://github.com/kailai-wang/musig2?branch=use-sha2-0.8#93857e52abbe8f9898c9ec743eecb1380132abcb" dependencies = [ "base16ct", "hmac", @@ -3112,11 +3125,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", "sp-runtime", @@ -3163,7 +3176,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3204,11 +3217,11 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", "sp-inherents", @@ -3220,7 +3233,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3234,9 +3247,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -3721,19 +3734,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.13.0 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.17", - "ring 0.16.19", - "sct", - "sgx_tstd", - "webpki", -] - [[package]] name = "rustls" version = "0.19.0" @@ -3938,15 +3938,6 @@ dependencies = [ "secp256k1-sys 0.9.1", ] -[[package]] -name = "secp256k1" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" -dependencies = [ - "secp256k1-sys 0.10.0", -] - [[package]] name = "secp256k1-sys" version = "0.6.1" @@ -3965,15 +3956,6 @@ dependencies = [ "cc", ] -[[package]] -name = "secp256k1-sys" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" -dependencies = [ - "cc", -] - [[package]] name = "secrecy" version = "0.8.0" @@ -4083,12 +4065,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_backtrace_sys" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "cc", "sgx_build_helper", @@ -4098,7 +4080,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_crypto_helper" @@ -4117,12 +4099,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_libc" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_types", ] @@ -4171,18 +4153,10 @@ dependencies = [ "sgx_types", ] -[[package]] -name = "sgx_tcrypto_helper" -version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" -dependencies = [ - "sgx_crypto_helper", -] - [[package]] name = "sgx_tprotected_fs" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_trts", "sgx_types", @@ -4248,7 +4222,7 @@ source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master [[package]] name = "sgx_unwind" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_build_helper", ] @@ -4384,9 +4358,9 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", "sp-api-proc-macro", @@ -4400,7 +4374,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "blake2", @@ -4414,7 +4388,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -4426,7 +4400,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "integer-sqrt", "num-traits 0.2.16", @@ -4439,10 +4413,10 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "finality-grandpa", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "scale-info", "sp-api", @@ -4455,7 +4429,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes", "bitflags", @@ -4465,7 +4439,7 @@ dependencies = [ "hash-db 0.16.0", "hash256-std-hasher", "libsecp256k1", - "log 0.4.17", + "log 0.4.21", "merlin", "parity-scale-codec", "paste", @@ -4486,7 +4460,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "blake2b_simd 1.0.2", "byteorder 1.4.3", @@ -4500,7 +4474,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -4511,7 +4485,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -4521,7 +4495,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "environmental 1.1.4", "parity-scale-codec", @@ -4532,7 +4506,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -4547,7 +4521,7 @@ version = "7.0.0" dependencies = [ "itp-sgx-externalities", "libsecp256k1", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "sgx_tstd", "sp-core", @@ -4556,7 +4530,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -4567,12 +4541,12 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "either", "hash256-std-hasher", "impl-trait-for-tuples", - "log 0.4.17", + "log 0.4.21", "parity-scale-codec", "paste", "scale-info", @@ -4587,7 +4561,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.5.0", "impl-trait-for-tuples", @@ -4605,7 +4579,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "proc-macro-crate", @@ -4617,7 +4591,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -4629,12 +4603,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "ref-cast", @@ -4645,7 +4619,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -4656,7 +4630,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-std", @@ -4667,7 +4641,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "memory-db", @@ -4682,7 +4656,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -4695,7 +4669,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -4706,7 +4680,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -4716,7 +4690,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -4800,7 +4774,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-compose-macros", "ac-node-api", @@ -5019,7 +4993,7 @@ checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ "hash-db 0.16.0", "hashbrown 0.13.2", - "log 0.4.17", + "log 0.4.21", "smallvec 1.11.1", ] @@ -5379,3 +5353,8 @@ dependencies = [ "quote 1.0.36", "syn 2.0.72", ] + +[[patch.unused]] +name = "sgx_tcrypto_helper" +version = "1.1.6" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" diff --git a/tee-worker/bitacross/enclave-runtime/Cargo.toml b/tee-worker/bitacross/enclave-runtime/Cargo.toml index 1237624816..064b3b8181 100644 --- a/tee-worker/bitacross/enclave-runtime/Cargo.toml +++ b/tee-worker/bitacross/enclave-runtime/Cargo.toml @@ -46,7 +46,7 @@ test = [ dcap = [] [target.'cfg(not(target_env = "sgx"))'.dependencies] -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_tcrypto_helper" } +sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", default-features = false, features = ["mesalock_sgx"] } sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } sgx_serialize = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } sgx_serialize_derive = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } @@ -68,7 +68,6 @@ lazy_static = { version = "1.1.0", features = ["spin_no_std"] } primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "serde_no_std"] } url = { git = "https://github.com/integritee-network/rust-url", branch = "sgx-no-std", default-features = false, features = ["alloc"] } - # scs / integritee jsonrpc-core = { default-features = false, git = "https://github.com/scs/jsonrpc", branch = "no_std_v18" } @@ -88,40 +87,40 @@ cid = { default-features = false, git = "https://github.com/whalelephant/rust-ci multibase = { default-features = false, git = "https://github.com/whalelephant/rust-multibase", branch = "nstd" } # local deps -ita-parentchain-interface = { path = "../app-libs/parentchain-interface", default-features = false, features = ["sgx"] } -ita-sgx-runtime = { path = "../app-libs/sgx-runtime", default-features = false } -ita-stf = { path = "../app-libs/stf", default-features = false, features = ["sgx"] } -itc-direct-rpc-server = { path = "../core/direct-rpc-server", default-features = false, features = ["sgx"] } -itc-offchain-worker-executor = { path = "../core/offchain-worker-executor", default-features = false, features = ["sgx"] } -itc-parentchain = { path = "../core/parentchain/parentchain-crate", default-features = false, features = ["sgx"] } -itc-parentchain-light-client = { path = "../core/parentchain/light-client", default-features = false } -itc-parentchain-test = { path = "../core/parentchain/test", default-features = false } -itc-tls-websocket-server = { path = "../core/tls-websocket-server", default-features = false, features = ["sgx"] } -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-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 } -itp-node-api-metadata-provider = { path = "../core-primitives/node-api/metadata-provider", default-features = false } -itp-nonce-cache = { path = "../core-primitives/nonce-cache", default-features = false, features = ["sgx"] } -itp-ocall-api = { path = "../core-primitives/ocall-api", default-features = false } -itp-primitives-cache = { path = "../core-primitives/primitives-cache", default-features = false, features = ["sgx"] } -itp-rpc = { path = "../core-primitives/rpc", default-features = false, features = ["sgx"] } -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-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-test = { path = "../core-primitives/test", default-features = false, optional = true } -itp-top-pool = { path = "../core-primitives/top-pool", default-features = false, features = ["sgx"] } -itp-top-pool-author = { path = "../core-primitives/top-pool-author", default-features = false, features = ["sgx"] } -itp-types = { path = "../core-primitives/types", default-features = false } -itp-utils = { path = "../core-primitives/utils", default-features = false } +ita-parentchain-interface = { package = "bc-ita-parentchain-interface", path = "../app-libs/parentchain-interface", default-features = false, features = ["sgx"] } +ita-sgx-runtime = { package = "bc-ita-sgx-runtime", path = "../app-libs/sgx-runtime", default-features = false } +ita-stf = { package = "bc-ita-stf", path = "../app-libs/stf", default-features = false, features = ["sgx"] } +itc-direct-rpc-server = { package = "bc-itc-direct-rpc-server", path = "../core/direct-rpc-server", default-features = false, features = ["sgx"] } +itc-offchain-worker-executor = { package = "bc-itc-offchain-worker-executor", path = "../core/offchain-worker-executor", default-features = false, features = ["sgx"] } +itc-parentchain = { package = "bc-itc-parentchain", path = "../core/parentchain/parentchain-crate", default-features = false, features = ["sgx"] } +itc-parentchain-light-client = { path = "../../common/core/parentchain/light-client", default-features = false } +itc-parentchain-test = { path = "../../common/core/parentchain/test", default-features = false } +itc-tls-websocket-server = { path = "../../common/core/tls-websocket-server", default-features = false, features = ["sgx"] } +itp-attestation-handler = { path = "../../common/core-primitives/attestation-handler", default-features = false, features = ["sgx"] } +itp-component-container = { path = "../../common/core-primitives/component-container", default-features = false, features = ["sgx"] } +itp-extrinsics-factory = { path = "../../common/core-primitives/extrinsics-factory", default-features = false, features = ["sgx"] } +itp-import-queue = { path = "../../common/core-primitives/import-queue", default-features = false, features = ["sgx"] } +itp-node-api = { path = "../../common/core-primitives/node-api", default-features = false, features = ["sgx"] } +itp-node-api-metadata = { path = "../../common/core-primitives/node-api/metadata", default-features = false } +itp-node-api-metadata-provider = { path = "../../common/core-primitives/node-api/metadata-provider", default-features = false } +itp-nonce-cache = { path = "../../common/core-primitives/nonce-cache", default-features = false, features = ["sgx"] } +itp-ocall-api = { path = "../../common/core-primitives/ocall-api", default-features = false } +itp-primitives-cache = { path = "../../common/core-primitives/primitives-cache", default-features = false, features = ["sgx"] } +itp-rpc = { path = "../../common/core-primitives/rpc", default-features = false, features = ["sgx"] } +itp-settings = { path = "../../common/core-primitives/settings" } +itp-sgx-crypto = { path = "../../common/core-primitives/sgx/crypto", default-features = false, features = ["sgx"] } +itp-sgx-externalities = { path = "../../common/core-primitives/substrate-sgx/externalities", default-features = false, features = ["sgx"] } +itp-stf-executor = { package = "bc-itp-stf-executor", path = "../core-primitives/stf-executor", default-features = false, features = ["sgx"] } +itp-stf-interface = { path = "../../common/core-primitives/stf-interface", default-features = false } +itp-stf-primitives = { path = "../../common/core-primitives/stf-primitives", default-features = false } +itp-stf-state-handler = { path = "../../common/core-primitives/stf-state-handler", default-features = false, features = ["sgx"] } +itp-stf-state-observer = { path = "../../common/core-primitives/stf-state-observer", default-features = false, features = ["sgx"] } +itp-storage = { path = "../../common/core-primitives/storage", default-features = false, features = ["sgx"] } +itp-test = { path = "../../common/core-primitives/test", default-features = false, optional = true } +itp-top-pool = { package = "bc-itp-top-pool", path = "../core-primitives/top-pool", default-features = false, features = ["sgx"] } +itp-top-pool-author = { package = "bc-itp-top-pool-author", path = "../core-primitives/top-pool-author", default-features = false, features = ["sgx"] } +itp-types = { path = "../../common/core-primitives/types", default-features = false } +itp-utils = { path = "../../common/core-primitives/utils", default-features = false } # litentry bc-enclave-registry = { path = "../bitacross/core/bc-enclave-registry", default-features = false, features = ["sgx"] } @@ -132,19 +131,19 @@ bc-task-sender = { path = "../bitacross/core/bc-task-sender", default-features = lc-direct-call = { path = "../litentry/core/direct-call", default-features = false } litentry-hex-utils = { path = "../../../common/utils/hex", default-features = false } litentry-macros = { path = "../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../litentry/primitives", default-features = false, features = ["sgx"] } +litentry-primitives = { path = "../../common/litentry/primitives", default-features = false, features = ["sgx"] } litentry-proc-macros = { path = "../../../common/primitives/core/proc-macros", default-features = false } # bitacross bc-task-processor = { path = "../bitacross/core/bc-task-processor", default-features = false, features = ["sgx"] } # substrate deps -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["full_crypto"] } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } # test-deps -itp-sgx-temp-dir = { version = "0.1", default-features = false, optional = true, path = "../core-primitives/sgx/temp-dir" } +itp-sgx-temp-dir = { path = "../../common/core-primitives/sgx/temp-dir", default-features = false, optional = true } [patch.crates-io] env_logger = { git = "https://github.com/integritee-network/env_logger-sgx" } @@ -155,7 +154,7 @@ ring = { git = "https://github.com/betrusted-io/ring-xous", branch = "0.16.20-cl log = { git = "https://github.com/integritee-network/log-sgx" } [patch."https://github.com/paritytech/substrate"] -sp-io = { path = "../core-primitives/substrate-sgx/sp-io" } +sp-io = { path = "../../common/core-primitives/substrate-sgx/sp-io" } [patch."https://github.com/apache/teaclave-sgx-sdk.git"] sgx_alloc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/common.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/common.rs index ec6bcf4a8e..1d45f55dc7 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/common.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/common.rs @@ -36,6 +36,11 @@ use crate::{ GLOBAL_SIGNER_REGISTRY, }, }; +use ita_parentchain_interface::{ + integritee::ParentchainEventHandler as LitentryParentchainEventHandler, + target_a::ParentchainEventHandler as TargetAParentchainEventHandler, + target_b::ParentchainEventHandler as TargetBParentchainEventHandler, +}; use itp_component_container::ComponentGetter; use itp_nonce_cache::NonceCache; use itp_sgx_crypto::key_repository::AccessKey; @@ -60,6 +65,8 @@ pub(crate) fn create_integritee_parentchain_block_importer( let signer_registry = GLOBAL_SIGNER_REGISTRY.get()?; let enclave_registry = GLOBAL_ENCLAVE_REGISTRY.get()?; + let parentchain_event_handler = LitentryParentchainEventHandler {}; + let stf_enclave_signer = Arc::new(EnclaveStfEnclaveSigner::new( state_observer, ocall_api.clone(), @@ -72,6 +79,7 @@ pub(crate) fn create_integritee_parentchain_block_importer( top_pool_author, node_metadata_repository, ParentchainId::Litentry, + parentchain_event_handler, relayer_registry, signer_registry, enclave_registry, @@ -102,6 +110,8 @@ pub(crate) fn create_target_a_parentchain_block_importer( let signer_registry = GLOBAL_SIGNER_REGISTRY.get()?; let enclave_registry = GLOBAL_ENCLAVE_REGISTRY.get()?; + let parentchain_event_handler = TargetAParentchainEventHandler {}; + let stf_enclave_signer = Arc::new(EnclaveStfEnclaveSigner::new( state_observer, ocall_api.clone(), @@ -114,6 +124,7 @@ pub(crate) fn create_target_a_parentchain_block_importer( top_pool_author, node_metadata_repository, ParentchainId::TargetA, + parentchain_event_handler, relayer_registry, signer_registry, enclave_registry, @@ -144,6 +155,8 @@ pub(crate) fn create_target_b_parentchain_block_importer( let signer_registry = GLOBAL_SIGNER_REGISTRY.get()?; let enclave_registry = GLOBAL_ENCLAVE_REGISTRY.get()?; + let parentchain_event_handler = TargetBParentchainEventHandler {}; + let stf_enclave_signer = Arc::new(EnclaveStfEnclaveSigner::new( state_observer, ocall_api.clone(), @@ -156,6 +169,7 @@ pub(crate) fn create_target_b_parentchain_block_importer( top_pool_author, node_metadata_repository, ParentchainId::TargetB, + parentchain_event_handler, relayer_registry, signer_registry, enclave_registry, diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs index 709c1e313e..f0cc06a94b 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs @@ -34,12 +34,11 @@ use crate::{ }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentGetter; +use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; -use itp_stf_interface::ShardCreationInfo; - #[derive(Clone)] pub struct IntegriteeParachainHandler { pub genesis_header: ParachainHeader, diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs index 8874cbb772..ee5697967f 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs @@ -34,12 +34,11 @@ use crate::{ }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentGetter; +use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; -use itp_stf_interface::ShardCreationInfo; - pub struct IntegriteeSolochainHandler { pub genesis_header: SolochainHeader, pub node_metadata_repository: Arc, diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/mod.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/mod.rs index 50fa5b84bb..d658ec6c36 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/mod.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/mod.rs @@ -38,11 +38,9 @@ use crate::{ use codec::{Decode, Encode}; use integritee_parachain::IntegriteeParachainHandler; use integritee_solochain::IntegriteeSolochainHandler; -use itc_parentchain::{ - light_client::{concurrent_access::ValidatorAccess, LightClientState}, - primitives::{ParentchainId, ParentchainInitParams}, -}; +use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentInitializer; +use itp_types::parentchain::{ParentchainId, ParentchainInitParams}; use log::*; use std::{path::PathBuf, vec::Vec}; diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs index d8d442d2a0..32de87cfba 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs @@ -37,10 +37,10 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; use itp_component_container::ComponentGetter; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; #[derive(Clone)] diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs index e618f37313..bd76a450f6 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs @@ -31,10 +31,10 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; use itp_component_container::ComponentGetter; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; pub struct TargetASolochainHandler { diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs index 18baef5916..221a37b0c0 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs @@ -37,10 +37,10 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; use itp_component_container::ComponentGetter; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; #[derive(Clone)] diff --git a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs index f21d5ac0d7..0953d15779 100644 --- a/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs +++ b/tee-worker/bitacross/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs @@ -31,10 +31,10 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; use itp_component_container::ComponentGetter; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; pub struct TargetBSolochainHandler { diff --git a/tee-worker/bitacross/enclave-runtime/src/lib.rs b/tee-worker/bitacross/enclave-runtime/src/lib.rs index 5800f628f6..07371a1cf7 100644 --- a/tee-worker/bitacross/enclave-runtime/src/lib.rs +++ b/tee-worker/bitacross/enclave-runtime/src/lib.rs @@ -68,7 +68,6 @@ use initialization::global_components::{ use itc_parentchain::{ block_import_dispatcher::DispatchBlockImport, light_client::{concurrent_access::ValidatorAccess, Validator}, - primitives::ParentchainId, }; use itp_component_container::ComponentGetter; use itp_node_api::metadata::NodeMetadata; @@ -77,7 +76,7 @@ use itp_nonce_cache::{MutateNonce, Nonce}; use itp_sgx_crypto::key_repository::AccessKey; use itp_sgx_crypto::key_repository::AccessPubkey; use itp_storage::{StorageProof, StorageProofChecker}; -use itp_types::{ShardIdentifier, SignedBlock}; +use itp_types::{parentchain::ParentchainId, ShardIdentifier, SignedBlock}; use itp_utils::write_slice_and_whitespace_pad; use litentry_macros::if_development_or; use log::*; diff --git a/tee-worker/bitacross/enclave-runtime/src/ocall/on_chain_ocall.rs b/tee-worker/bitacross/enclave-runtime/src/ocall/on_chain_ocall.rs index 95b9183269..e80c1fb112 100644 --- a/tee-worker/bitacross/enclave-runtime/src/ocall/on_chain_ocall.rs +++ b/tee-worker/bitacross/enclave-runtime/src/ocall/on_chain_ocall.rs @@ -19,10 +19,11 @@ use crate::ocall::{ffi, OcallApi}; use codec::{Decode, Encode}; use frame_support::ensure; -use itc_parentchain::primitives::ParentchainId; use itp_ocall_api::{EnclaveOnChainOCallApi, Result}; use itp_storage::{verify_storage_entries, Error as StorageError}; -use itp_types::{storage::StorageEntryVerified, WorkerRequest, WorkerResponse, H256}; +use itp_types::{ + parentchain::ParentchainId, storage::StorageEntryVerified, WorkerRequest, WorkerResponse, H256, +}; use log::*; use sgx_types::*; use sp_runtime::{traits::Header, OpaqueExtrinsic}; diff --git a/tee-worker/bitacross/example/client/definitions.json b/tee-worker/bitacross/example/client/definitions.json index af77e7670b..4824d890fa 100644 --- a/tee-worker/bitacross/example/client/definitions.json +++ b/tee-worker/bitacross/example/client/definitions.json @@ -23,9 +23,74 @@ "Ok", "()" ], + [ + "TrustedOperationStatus", + "(TrustedOperationStatus, H256)" + ], [ "Error", "()" + ], + [ + "Processing", + "H256" + ] + ] + }, + "TrustedOperationStatus": { + "type": "enum", + "type_mapping": [ + [ + "Submitted", + "()" + ], + [ + "Future", + "()" + ], + [ + "Ready", + "()" + ], + [ + "Broadcast", + "()" + ], + [ + "InSidechainBlock", + "H256" + ], + [ + "Retracted", + "()" + ], + [ + "FinalityTimeout", + "()" + ], + [ + "Finalized", + "()" + ], + [ + "Usurped", + "()" + ], + [ + "Dropped", + "()" + ], + [ + "Invalid", + "()" + ], + [ + "TopExecuted", + "(Vec, bool)" + ], + [ + "SuccessorExecuted", + "()" ] ] }, diff --git a/tee-worker/bitacross/litentry/core/direct-call/Cargo.toml b/tee-worker/bitacross/litentry/core/direct-call/Cargo.toml index 632f5e1454..749225754d 100644 --- a/tee-worker/bitacross/litentry/core/direct-call/Cargo.toml +++ b/tee-worker/bitacross/litentry/core/direct-call/Cargo.toml @@ -5,29 +5,28 @@ name = "lc-direct-call" version = "0.1.0" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } # internal dependencies bc-enclave-registry = { path = "../../../bitacross/core/bc-enclave-registry", default-features = false } bc-musig2-ceremony = { path = "../../../bitacross/core/bc-musig2-ceremony", default-features = false } bc-relayer-registry = { path = "../../../bitacross/core/bc-relayer-registry", default-features = false } bc-signer-registry = { path = "../../../bitacross/core/bc-signer-registry", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-stf-primitives = { path = "../../../core-primitives/stf-primitives", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } -log = { version = "0.4", default-features = false } +itp-sgx-crypto = { workspace = true } +itp-stf-primitives = { workspace = true } +litentry-primitives = { workspace = true } -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true } +sgx_tstd = { workspace = true, optional = true } [dev-dependencies] -k256 = { version = "0.13.3", features = ["ecdsa-core", "schnorr"] } -rand = { version = "0.7" } -hex = { version = "0.4" } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", features = ["mocks"] } +k256 = { workspace = true, features = ["ecdsa-core", "schnorr"] } +rand = { workspace = true } +hex = { workspace = true } +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } [features] default = ["std"] @@ -53,6 +52,7 @@ std = [ "litentry-primitives/std", "sp-core/std", "sp-io/std", + "codec/std", ] test = [ "itp-sgx-crypto/mocks", diff --git a/tee-worker/bitacross/litentry/core/teebag-storage/Cargo.toml b/tee-worker/bitacross/litentry/core/teebag-storage/Cargo.toml deleted file mode 100644 index c68b9e0d5e..0000000000 --- a/tee-worker/bitacross/litentry/core/teebag-storage/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "lc-teebag-storage" -version = "0.1.0" -authors = ['Trust Computing GmbH '] -edition = "2021" - -[dependencies] -itp-storage = { path = "../../../core-primitives/storage", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } - -[features] -default = ["std"] -std = [ - "sp-std/std", - "itp-storage/std", - "itp-types/std", -] diff --git a/tee-worker/bitacross/litentry/primitives/Cargo.toml b/tee-worker/bitacross/litentry/primitives/Cargo.toml deleted file mode 100644 index b28bc15c63..0000000000 --- a/tee-worker/bitacross/litentry/primitives/Cargo.toml +++ /dev/null @@ -1,60 +0,0 @@ -[package] -authors = ["Trust Computing GmbH "] -edition = "2021" -name = "litentry-primitives" -version = "0.1.0" - -[dependencies] -bitcoin = { version = "0.31.0", default-features = false, features = ["secp-recovery", "no-std"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false } -log = { version = "0.4", default-features = false } -rand = { version = "0.7", optional = true } -rand-sgx = { package = "rand", git = "https://github.com/mesalock-linux/rand-sgx", tag = "sgx_1.1.3", features = ["sgx_tstd"], optional = true } -ring = { version = "0.16.20", default-features = false } -scale-info = { version = "2.4.0", default-features = false, features = ["derive"] } -secp256k1 = { version = "0.28.0", default-features = false } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } - -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } - -# internal dependencies -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false } -litentry-hex-utils = { path = "../../../../common/utils/hex", default-features = false } -pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } -parentchain-primitives = { package = "core-primitives", git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } - -[dev-dependencies] -base64 = { version = "0.13", features = ["alloc"] } - -[features] -default = ["std"] -development = [ - "parentchain-primitives/development", -] -sgx = [ - "sgx_tstd", - "rand-sgx", - "itp-sgx-crypto/sgx", -] -std = [ - "hex/std", - "serde/std", - "itp-sgx-crypto/std", - "sp-core/std", - "sp-std/std", - "sp-io/std", - "sp-runtime/std", - "ring/std", - "parentchain-primitives/std", - "pallet-teebag/std", - "rand", - "log/std", - "bitcoin/std", - "secp256k1/std", -] diff --git a/tee-worker/bitacross/litentry/primitives/src/bitcoin_address.rs b/tee-worker/bitacross/litentry/primitives/src/bitcoin_address.rs deleted file mode 100644 index 32dcdcafcb..0000000000 --- a/tee-worker/bitacross/litentry/primitives/src/bitcoin_address.rs +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 bitcoin::{ - address::Address, key::PublicKey, network::Network, secp256k1::Secp256k1, XOnlyPublicKey, -}; -use core::str::FromStr; -use std::string::{String, ToString}; - -// Some dependency conflict of bitcoin crate with enclave building -// when putting these functions into core-premitives/utils. -pub fn p2wpkh_address(pubkey_string: &str) -> String { - let pubkey = PublicKey::from_str(pubkey_string).expect("pubkey"); - let address = Address::p2wpkh(&pubkey, Network::Bitcoin); - if let Ok(address) = address { - return address.to_string() - } - "".to_string() -} - -pub fn p2sh_address(pubkey_string: &str) -> String { - let pubkey = PublicKey::from_str(pubkey_string).expect("pubkey"); - let address = Address::p2shwpkh(&pubkey, Network::Bitcoin); - if let Ok(address) = address { - return address.to_string() - } - "".to_string() -} - -pub fn p2tr_address(pubkey_string: &str) -> String { - let pubkey = PublicKey::from_str(pubkey_string).expect("pubkey"); - let xonly_pubkey = XOnlyPublicKey::from(pubkey.inner); - // unisat wallet uses is this way - let secp = Secp256k1::verification_only(); - let address = Address::p2tr(&secp, xonly_pubkey, None, Network::Bitcoin); - address.to_string() -} - -pub fn p2pkh_address(pubkey_string: &str) -> String { - let pubkey = PublicKey::from_str(pubkey_string).expect("pubkey"); - let address = Address::p2pkh(&pubkey, Network::Bitcoin); - address.to_string() -} diff --git a/tee-worker/bitacross/litentry/primitives/src/lib.rs b/tee-worker/bitacross/litentry/primitives/src/lib.rs deleted file mode 100644 index fc568f256c..0000000000 --- a/tee-worker/bitacross/litentry/primitives/src/lib.rs +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2020-2024 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 . - -#![cfg_attr(not(feature = "std"), no_std)] - -extern crate core; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -mod aes; -mod bitcoin_address; -mod bitcoin_signature; -mod ethereum_signature; -mod plain_request; -mod validation_data; - -pub use aes::*; -pub use bitcoin_address::*; -pub use bitcoin_signature::*; -pub use ethereum_signature::*; -pub use plain_request::*; -use sp_std::{boxed::Box, fmt::Debug, vec::Vec}; -pub use validation_data::*; - -use bitcoin::sign_message::{signed_msg_hash, MessageSignature}; -use codec::{Decode, Encode, MaxEncodedLen}; -use itp_sgx_crypto::ShieldingCryptoDecrypt; -use litentry_hex_utils::hex_encode; -use log::error; -pub use pallet_teebag::{ - decl_rsa_request, extract_tcb_info_from_raw_dcap_quote, AttestationType, DcapProvider, Enclave, - EnclaveFingerprint, MrEnclave, ShardIdentifier, SidechainBlockNumber, WorkerMode, WorkerType, -}; -pub use parentchain_primitives::{ - identity::*, AccountId as ParentchainAccountId, Balance as ParentchainBalance, - BlockNumber as ParentchainBlockNumber, ErrorDetail, ErrorString, Hash as ParentchainHash, - Header as ParentchainHeader, Index as ParentchainIndex, ParameterString, - Signature as ParentchainSignature, MINUTES, -}; -use scale_info::TypeInfo; -use sp_core::{ecdsa, ed25519, sr25519, ByteArray}; -use sp_io::{ - crypto::secp256k1_ecdsa_recover, - hashing::{blake2_256, keccak_256}, -}; -use sp_runtime::traits::Verify; -use std::string::{String, ToString}; - -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; - -pub const LITENTRY_PRETTIFIED_MESSAGE_PREFIX: &str = "Litentry authorization token: "; - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub enum LitentryMultiSignature { - /// An Ed25519 signature. - #[codec(index = 0)] - Ed25519(ed25519::Signature), - /// An Sr25519 signature. - #[codec(index = 1)] - Sr25519(sr25519::Signature), - /// An ECDSA/SECP256k1 signature. - #[codec(index = 2)] - Ecdsa(ecdsa::Signature), - /// An ECDSA/keccak256 signature. An Ethereum signature. hash message with keccak256 - #[codec(index = 3)] - Ethereum(EthereumSignature), - /// Same as above, but the payload bytes are prepended with a readable prefix and `0x` - #[codec(index = 4)] - EthereumPrettified(EthereumSignature), - /// Bitcoin signed message, a hex-encoded string of original &[u8] message, without `0x` prefix - #[codec(index = 5)] - Bitcoin(BitcoinSignature), - /// Same as above, but the payload bytes are prepended with a readable prefix and `0x` - #[codec(index = 6)] - BitcoinPrettified(BitcoinSignature), -} - -impl LitentryMultiSignature { - pub fn verify(&self, msg: &[u8], signer: &Identity) -> bool { - match signer { - Identity::Substrate(address) => - self.verify_substrate(substrate_wrap(msg).as_slice(), address) - || self.verify_substrate(msg, address), - Identity::Evm(address) => self.verify_evm(msg, address), - Identity::Bitcoin(address) => self.verify_bitcoin(msg, address), - Identity::Solana(address) => self.verify_solana(msg, address), - _ => false, - } - } - - fn verify_substrate(&self, msg: &[u8], signer: &Address32) -> bool { - match (self, signer) { - (Self::Ed25519(ref sig), who) => match ed25519::Public::from_slice(who.as_ref()) { - Ok(signer) => sig.verify(msg, &signer), - Err(()) => false, - }, - (Self::Sr25519(ref sig), who) => match sr25519::Public::from_slice(who.as_ref()) { - Ok(signer) => sig.verify(msg, &signer), - Err(()) => false, - }, - (Self::Ecdsa(ref sig), who) => { - let m = blake2_256(msg); - match sp_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) { - Ok(pubkey) => - &blake2_256(pubkey.as_ref()) == >::as_ref(who), - _ => false, - } - }, - _ => false, - } - } - - fn verify_evm(&self, msg: &[u8], signer: &Address20) -> bool { - match self { - Self::Ethereum(ref sig) => - return verify_evm_signature(evm_eip191_wrap(msg).as_slice(), sig, signer) - || verify_evm_signature(msg, sig, signer), - Self::EthereumPrettified(ref sig) => { - let prettified_msg = - LITENTRY_PRETTIFIED_MESSAGE_PREFIX.to_string() + &hex_encode(msg); - let msg = prettified_msg.as_bytes(); - return verify_evm_signature(evm_eip191_wrap(msg).as_slice(), sig, signer) - || verify_evm_signature(msg, sig, signer) - }, - _ => false, - } - } - - fn verify_bitcoin(&self, msg: &[u8], signer: &Address33) -> bool { - match self { - Self::Bitcoin(ref sig) => - verify_bitcoin_signature(hex::encode(msg).as_str(), sig, signer), - Self::BitcoinPrettified(ref sig) => { - let prettified_msg = - LITENTRY_PRETTIFIED_MESSAGE_PREFIX.to_string() + &hex_encode(msg); - verify_bitcoin_signature(prettified_msg.as_str(), sig, signer) - }, - _ => false, - } - } - - // https://github.com/solana-labs/solana/blob/master/docs/src/proposals/off-chain-message-signing.md - fn verify_solana(&self, msg: &[u8], signer: &Address32) -> bool { - match (self, signer) { - (Self::Ed25519(ref sig), who) => match ed25519::Public::from_slice(who.as_ref()) { - Ok(signer) => sig.verify(msg, &signer), - Err(()) => false, - }, - _ => false, - } - } -} - -pub fn verify_evm_signature(msg: &[u8], sig: &EthereumSignature, who: &Address20) -> bool { - let digest = keccak_256(msg); - return match recover_evm_address(&digest, sig.as_ref()) { - Ok(recovered_evm_address) => recovered_evm_address == who.as_ref().as_slice(), - Err(_e) => { - error!("Could not verify evm signature msg: {:?}, signer {:?}", msg, who); - false - }, - } -} - -pub fn verify_bitcoin_signature(msg: &str, sig: &BitcoinSignature, who: &Address33) -> bool { - if let Ok(msg_sig) = MessageSignature::from_slice(sig.as_ref()) { - let msg_hash = signed_msg_hash(msg); - let secp = secp256k1::Secp256k1::new(); - return match msg_sig.recover_pubkey(&secp, msg_hash) { - Ok(recovered_pub_key) => &recovered_pub_key.inner.serialize() == who.as_ref(), - Err(_) => { - error!("Could not recover pubkey from bitcoin msg: {:?}, signer {:?}", msg, who); - false - }, - } - } - - false -} - -impl From for LitentryMultiSignature { - fn from(x: ed25519::Signature) -> Self { - Self::Ed25519(x) - } -} - -impl From for LitentryMultiSignature { - fn from(x: sr25519::Signature) -> Self { - Self::Sr25519(x) - } -} - -impl From for LitentryMultiSignature { - fn from(x: ecdsa::Signature) -> Self { - Self::Ecdsa(x) - } -} - -pub fn recover_evm_address( - msg: &[u8; 32], - sig: &[u8; 65], -) -> Result<[u8; 20], sp_io::EcdsaVerifyError> { - let pubkey = secp256k1_ecdsa_recover(sig, msg)?; - let hashed_pk = keccak_256(&pubkey); - - let mut addr = [0u8; 20]; - addr[..20].copy_from_slice(&hashed_pk[12..32]); - Ok(addr) -} - -// see https://github.com/litentry/litentry-parachain/issues/1137 -fn substrate_wrap(msg: &[u8]) -> Vec { - ["".as_bytes(), msg, "".as_bytes()].concat() -} - -// see https://github.com/litentry/litentry-parachain/issues/1970 -fn evm_eip191_wrap(msg: &[u8]) -> Vec { - ["\x19Ethereum Signed Message:\n".as_bytes(), msg.len().to_string().as_bytes(), msg].concat() -} - -// Represent a request that can be decrypted by the enclave -// Both itp_types::RsaRequest and AesRequest should impelement this -pub trait DecryptableRequest { - type Error; - // the shard getter - fn shard(&self) -> ShardIdentifier; - // the raw payload - AFAICT only used in mock - fn payload(&self) -> &[u8]; - // how to decrypt the payload - fn decrypt( - &mut self, - enclave_shielding_key: Box>, - ) -> Result, Self::Error>; -} - -pub struct BroadcastedRequest { - pub id: String, - pub payload: String, - pub rpc_method: String, -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn verify_bitcoin_signature_works() { - // generated by unisat-wallet API: https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet - let msg: Vec = vec![ - 3, 93, 250, 112, 216, 101, 89, 57, 83, 88, 100, 252, 203, 15, 64, 127, 138, 37, 2, 40, - 147, 95, 245, 27, 97, 202, 62, 205, 151, 0, 175, 177, - ]; - let pubkey: Vec = vec![ - 3, 93, 250, 112, 216, 101, 89, 57, 83, 88, 100, 252, 203, 15, 64, 127, 138, 37, 2, 40, - 147, 95, 245, 27, 97, 202, 62, 205, 151, 0, 175, 177, 216, - ]; - let sig: Vec = base64::decode("G2LhyYzWT2o8UoBsuhJsqFgwm3tlE0cW4aseCXKqVuNATk6K/uEHlPzDFmtlMADywDHl5vLCWcNpwmQLD7n/yvc=").unwrap(); - - let pubkey_ref: &[u8] = pubkey.as_ref(); - let sig_ref: &[u8] = sig.as_ref(); - assert!(verify_bitcoin_signature( - hex::encode(msg).as_str(), - &sig_ref.try_into().unwrap(), - &pubkey_ref.try_into().unwrap() - )); - } - - #[test] - fn verify_solana_signature_works() { - let signer = - Identity::from_did("did:litentry:solana:E9SegbpSr21FPLbUhoTNH6C2ja7KDkptybqSaT84wMH6") - .unwrap(); - let signature: [u8; 64] = [ - 62, 25, 148, 186, 53, 137, 248, 174, 149, 187, 225, 24, 186, 48, 24, 109, 100, 27, 149, - 196, 66, 5, 222, 140, 22, 16, 136, 239, 154, 22, 133, 96, 79, 2, 180, 106, 150, 112, - 116, 11, 6, 35, 32, 4, 145, 240, 54, 130, 206, 193, 200, 57, 241, 112, 35, 122, 226, - 97, 174, 231, 221, 13, 98, 2, - ]; - let result = LitentryMultiSignature::Ed25519(ed25519::Signature::from_raw(signature)) - .verify(b"test message", &signer); - assert_eq!(result, true); - } -} diff --git a/tee-worker/bitacross/litentry/primitives/src/validation_data.rs b/tee-worker/bitacross/litentry/primitives/src/validation_data.rs deleted file mode 100644 index 1dafbb5578..0000000000 --- a/tee-worker/bitacross/litentry/primitives/src/validation_data.rs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2020-2024 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 . - -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; - -use crate::LitentryMultiSignature; -use codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::{traits::ConstU32, BoundedVec}; - -// The size limit value should be 128 otherwise the message size will exceed the limit while link identity. -pub type ValidationString = BoundedVec>; - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub struct TwitterValidationData { - pub tweet_id: ValidationString, -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub struct DiscordValidationData { - pub channel_id: ValidationString, - pub message_id: ValidationString, - pub guild_id: ValidationString, -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub struct Web3CommonValidationData { - pub message: ValidationString, // or String if under std - pub signature: LitentryMultiSignature, -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[allow(non_camel_case_types)] -pub enum Web2ValidationData { - #[codec(index = 0)] - Twitter(TwitterValidationData), - #[codec(index = 1)] - Discord(DiscordValidationData), -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[allow(non_camel_case_types)] -pub enum Web3ValidationData { - #[codec(index = 0)] - Substrate(Web3CommonValidationData), - #[codec(index = 1)] - Evm(Web3CommonValidationData), - #[codec(index = 2)] - Bitcoin(Web3CommonValidationData), - #[codec(index = 3)] - Solana(Web3CommonValidationData), -} - -impl Web3ValidationData { - pub fn message(&self) -> &ValidationString { - match self { - Self::Substrate(data) => &data.message, - Self::Evm(data) => &data.message, - Self::Bitcoin(data) => &data.message, - Self::Solana(data) => &data.message, - } - } - - pub fn signature(&self) -> &LitentryMultiSignature { - match self { - Self::Substrate(data) => &data.signature, - Self::Evm(data) => &data.signature, - Self::Bitcoin(data) => &data.signature, - Self::Solana(data) => &data.signature, - } - } -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub enum ValidationData { - #[codec(index = 0)] - Web2(Web2ValidationData), - #[codec(index = 1)] - Web3(Web3ValidationData), -} diff --git a/tee-worker/bitacross/service/Cargo.toml b/tee-worker/bitacross/service/Cargo.toml index 36a9a2acd2..28aa4f6ecf 100644 --- a/tee-worker/bitacross/service/Cargo.toml +++ b/tee-worker/bitacross/service/Cargo.toml @@ -9,65 +9,60 @@ edition = '2021' async-trait = "0.1.50" base58 = "0.2" clap = { version = "2.33", features = ["yaml"] } +codec = { package = "parity-scale-codec", workspace = true } dirs = "3.0.2" -env_logger = "0.9" -futures = "0.3" -hex = "0.4.3" +env_logger = { workspace = true } +futures = { workspace = true, features = ["std"] } +hex = { workspace = true, features = ["std"] } humantime = "2.1" jsonrpsee = { version = "0.2.0", features = ["client", "ws-server", "macros"] } -lazy_static = "1.4.0" -log = "0.4" +lazy_static = { workspace = true } +log = { workspace = true, features = ["std"] } parking_lot = "0.12.1" parse_duration = "2.1.1" prometheus = { version = "0.13.0", features = ["process"], default-features = false } # Enabling std lead to protobuf dependency conflicts with substrate, and we don't need it. rayon = "1.10.0" regex = "1.9.5" -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" -thiserror = "1.0" +scale-info = { workspace = true } +serde = { workspace = true, features = ["std"] } +serde_derive = { workspace = true } +serde_json = { workspace = true, features = ["std"] } +thiserror = { workspace = true } tokio = { version = "1.6.1", features = ["full"] } url = "2.5.0" -warp = "0.3" +warp = "=0.3.5" -# ipfs ipfs-api = "0.11.0" -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +sgx_crypto_helper = { workspace = true, features = ["ucrypto_help"] } +sgx_types = { workspace = true } -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +ita-parentchain-interface = { package = "bc-ita-parentchain-interface", path = "../app-libs/parentchain-interface" } +itc-parentchain = { package = "bc-itc-parentchain", path = "../core/parentchain/parentchain-crate" } +itc-rest-client = { workspace = true, features = ["std"] } +itc-rpc-client = { workspace = true } +itp-api-client-types = { workspace = true, features = ["std"] } +itp-enclave-api = { package = "bc-itp-enclave-api", path = "../core-primitives/enclave-api" } +itp-enclave-metrics = { workspace = true, features = ["std"] } +itp-node-api = { workspace = true, features = ["std"] } +itp-settings = { workspace = true } +itp-stf-interface = { workspace = true, features = ["std"] } +itp-storage = { workspace = true, features = ["std"] } +itp-time-utils = { workspace = true, features = ["std"] } +itp-types = { workspace = true, features = ["std"] } +itp-utils = { workspace = true, features = ["std"] } -# local -ita-parentchain-interface = { path = "../app-libs/parentchain-interface" } -itc-parentchain = { path = "../core/parentchain/parentchain-crate" } -itc-rest-client = { path = "../core/rest-client" } -itc-rpc-client = { path = "../core/rpc-client" } -itp-api-client-types = { path = "../core-primitives/node-api/api-client-types" } -itp-enclave-api = { path = "../core-primitives/enclave-api" } -itp-enclave-metrics = { path = "../core-primitives/enclave-metrics" } -itp-node-api = { path = "../core-primitives/node-api" } -itp-settings = { path = "../core-primitives/settings" } -itp-stf-interface = { path = "../core-primitives/stf-interface" } -itp-storage = { path = "../core-primitives/storage" } -itp-time-utils = { path = "../core-primitives/time-utils" } -itp-types = { path = "../core-primitives/types" } -itp-utils = { path = "../core-primitives/utils" } - -# `default-features = false` to remove the jsonrpsee dependency. -substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } +substrate-api-client = { workspace = true } -# Substrate dependencies -frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", features = ["full_crypto"] } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { workspace = true, features = ["std"] } +sp-consensus-grandpa = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std", "full_crypto"] } +sp-keyring = { workspace = true } +sp-runtime = { workspace = true, features = ["std"] } # litentry config = "0.13.3" -litentry-primitives = { path = "../litentry/primitives" } +litentry-primitives = { workspace = true, features = ["std"] } [features] default = [] @@ -95,5 +90,5 @@ link-binary = [ anyhow = "1.0.40" mockall = "0.11" # local -itc-parentchain-test = { path = "../core/parentchain/test" } -itp-sgx-crypto = { path = "../core-primitives/sgx/crypto" } +itc-parentchain-test = { workspace = true, features = ["std"] } +itp-sgx-crypto = { workspace = true, features = ["std"] } diff --git a/tee-worker/bitacross/service/src/main_impl.rs b/tee-worker/bitacross/service/src/main_impl.rs index f68e11a1ad..663f2df117 100644 --- a/tee-worker/bitacross/service/src/main_impl.rs +++ b/tee-worker/bitacross/service/src/main_impl.rs @@ -52,8 +52,7 @@ use substrate_api_client::{ use litentry_primitives::extract_tcb_info_from_raw_dcap_quote; use crate::error::ServiceResult; -use itc_parentchain::primitives::ParentchainId; -use itp_types::parentchain::{AccountId, Balance}; +use itp_types::parentchain::{AccountId, Balance, ParentchainId}; use sp_core::{ crypto::{AccountId32, Ss58Codec}, Pair, diff --git a/tee-worker/bitacross/service/src/parentchain_handler.rs b/tee-worker/bitacross/service/src/parentchain_handler.rs index a87f927f10..7e0bc5242e 100644 --- a/tee-worker/bitacross/service/src/parentchain_handler.rs +++ b/tee-worker/bitacross/service/src/parentchain_handler.rs @@ -20,16 +20,15 @@ use crate::error::{Error, ServiceResult}; use codec::{Decode, Encode}; use humantime::format_duration; use ita_parentchain_interface::integritee::Header; -use itc_parentchain::{ - light_client::light_client_init_params::{GrandpaParams, SimpleParams}, - primitives::{ParentchainId, ParentchainInitParams}, -}; use itp_api_client_types::ParentchainApi; use itp_enclave_api::{enclave_base::EnclaveBase, sidechain::Sidechain}; use itp_node_api::api_client::ChainApi; use itp_storage::StorageProof; use itp_time_utils::duration_now; -use itp_types::ShardIdentifier; +use itp_types::{ + parentchain::{GrandpaParams, ParentchainId, ParentchainInitParams, SimpleParams}, + ShardIdentifier, +}; use log::*; use rayon::prelude::*; use sp_consensus_grandpa::VersionedAuthorityList; diff --git a/tee-worker/bitacross/service/src/prometheus_metrics.rs b/tee-worker/bitacross/service/src/prometheus_metrics.rs index 3b48024d92..6f0444bfe6 100644 --- a/tee-worker/bitacross/service/src/prometheus_metrics.rs +++ b/tee-worker/bitacross/service/src/prometheus_metrics.rs @@ -150,6 +150,7 @@ impl ReceiveEnclaveMetrics for EnclaveMetricsReceiver { }, EnclaveMetric::Musig2CeremonyDuration(time) => MUSIG2_CEREMONY_DURATION.observe(time.as_secs_f64()), + _ => warn!("Not supported metric: {:?}", metric), } Ok(()) } diff --git a/tee-worker/bitacross/service/src/tests/mocks/enclave_api_mock.rs b/tee-worker/bitacross/service/src/tests/mocks/enclave_api_mock.rs index fb212ce886..8e47e6cada 100644 --- a/tee-worker/bitacross/service/src/tests/mocks/enclave_api_mock.rs +++ b/tee-worker/bitacross/service/src/tests/mocks/enclave_api_mock.rs @@ -17,17 +17,16 @@ use codec::{Decode, Encode}; use core::fmt::Debug; -use itc_parentchain::primitives::{ - ParentchainId, ParentchainInitParams, - ParentchainInitParams::{Parachain, Solochain}, -}; use itp_enclave_api::{enclave_base::EnclaveBase, sidechain::Sidechain, EnclaveResult}; use itp_settings::worker::MR_ENCLAVE_SIZE; use itp_sgx_crypto::{ecdsa, schnorr}; use itp_stf_interface::ShardCreationInfo; use itp_storage::StorageProof; use itp_types::{ - parentchain::{Balance, Header}, + parentchain::{ + Balance, Header, ParentchainId, ParentchainInitParams, + ParentchainInitParams::{Parachain, Solochain}, + }, EnclaveFingerprint, ShardIdentifier, }; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/AttestationReportSigningCACert.pem b/tee-worker/common/core-primitives/attestation-handler/AttestationReportSigningCACert.pem similarity index 100% rename from tee-worker/bitacross/core-primitives/attestation-handler/AttestationReportSigningCACert.pem rename to tee-worker/common/core-primitives/attestation-handler/AttestationReportSigningCACert.pem diff --git a/tee-worker/common/core-primitives/attestation-handler/Cargo.toml b/tee-worker/common/core-primitives/attestation-handler/Cargo.toml new file mode 100644 index 0000000000..2fa96ba7c5 --- /dev/null +++ b/tee-worker/common/core-primitives/attestation-handler/Cargo.toml @@ -0,0 +1,94 @@ +[package] +name = "itp-attestation-handler" +version = "0.8.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +arrayvec = { workspace = true } +bit-vec = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +itertools = { workspace = true } +log = { workspace = true } + +base64 = { workspace = true, optional = true } +chrono = { workspace = true, optional = true } +rustls = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true, features = ["preserve_order"] } +thiserror = { workspace = true, optional = true } +webpki = { workspace = true, optional = true } + +base64_sgx = { workspace = true, optional = true } +chrono_sgx = { workspace = true, optional = true } +num-bigint = { workspace = true, optional = true } +rustls_sgx = { workspace = true, features = ["dangerous_configuration"], optional = true } +serde_json_sgx = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } +webpki-roots = { workspace = true } +webpki_sgx = { workspace = true, optional = true } +yasna_sgx = { workspace = true, optional = true } + +sgx_rand = { workspace = true, optional = true } +sgx_tcrypto = { workspace = true, optional = true } +sgx_tse = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["untrusted_fs", "net", "backtrace"], optional = true } +sgx_types = { workspace = true, features = ["extra_traits"] } + +itp-ocall-api = { workspace = true } +itp-settings = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-io = { workspace = true } +itp-time-utils = { workspace = true } + +httparse = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } + +[features] +default = ["std"] +std = [ + # crates-io no_std + "arrayvec/std", + "codec/std", + "hex/std", + "log/std", + "itertools/use_std", + # optional std only + "base64", + "chrono", + "rustls", + "serde_json", + "thiserror", + "webpki", + # local + "itp-ocall-api/std", + "itp-sgx-io/std", + "itp-sgx-crypto/std", + # substrate + "sp-core/std", + # integritee + "httparse/std", +] + +sgx = [ + # sgx-only + "base64_sgx", + "chrono_sgx", + "rustls_sgx", + "serde_json_sgx", + "thiserror_sgx", + "webpki_sgx", + "yasna_sgx", + "sgx_tse", + "sgx_tstd", + "sgx_rand", + "sgx_tcrypto", + "num-bigint", + # local + "itp-sgx-io/sgx", + "itp-sgx-crypto/sgx", + # integritee + "httparse/mesalock_sgx", +] +test = [] +development = [] diff --git a/tee-worker/identity/core-primitives/attestation-handler/src/attestation_handler.rs b/tee-worker/common/core-primitives/attestation-handler/src/attestation_handler.rs similarity index 100% rename from tee-worker/identity/core-primitives/attestation-handler/src/attestation_handler.rs rename to tee-worker/common/core-primitives/attestation-handler/src/attestation_handler.rs diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/src/cert.rs b/tee-worker/common/core-primitives/attestation-handler/src/cert.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/attestation-handler/src/cert.rs rename to tee-worker/common/core-primitives/attestation-handler/src/cert.rs diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/src/collateral.rs b/tee-worker/common/core-primitives/attestation-handler/src/collateral.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/attestation-handler/src/collateral.rs rename to tee-worker/common/core-primitives/attestation-handler/src/collateral.rs diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/src/error.rs b/tee-worker/common/core-primitives/attestation-handler/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/attestation-handler/src/error.rs rename to tee-worker/common/core-primitives/attestation-handler/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/attestation-handler/src/lib.rs b/tee-worker/common/core-primitives/attestation-handler/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/attestation-handler/src/lib.rs rename to tee-worker/common/core-primitives/attestation-handler/src/lib.rs diff --git a/tee-worker/common/core-primitives/binary-merkle-tree/Cargo.toml b/tee-worker/common/core-primitives/binary-merkle-tree/Cargo.toml new file mode 100644 index 0000000000..18d9fa8061 --- /dev/null +++ b/tee-worker/common/core-primitives/binary-merkle-tree/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "itp-binary-merkle-tree" +version = "0.8.0" +edition = "2021" + +[dependencies] +binary-merkle-tree = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true } +serde = { workspace = true } + +[features] +std = [ + "codec/std", + "serde/std", + "binary-merkle-tree/std", +] diff --git a/tee-worker/bitacross/core-primitives/binary-merkle-tree/src/lib.rs b/tee-worker/common/core-primitives/binary-merkle-tree/src/lib.rs similarity index 98% rename from tee-worker/bitacross/core-primitives/binary-merkle-tree/src/lib.rs rename to tee-worker/common/core-primitives/binary-merkle-tree/src/lib.rs index 9dc9ecd364..9c9e60211c 100644 --- a/tee-worker/bitacross/core-primitives/binary-merkle-tree/src/lib.rs +++ b/tee-worker/common/core-primitives/binary-merkle-tree/src/lib.rs @@ -25,7 +25,7 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::vec::Vec; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; // re-export the original one implementing all the merkle/logic. diff --git a/tee-worker/common/core-primitives/component-container/Cargo.toml b/tee-worker/common/core-primitives/component-container/Cargo.toml new file mode 100644 index 0000000000..7f47d661c7 --- /dev/null +++ b/tee-worker/common/core-primitives/component-container/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "itp-component-container" +version = "0.8.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/component-container/src/atomic_container.rs b/tee-worker/common/core-primitives/component-container/src/atomic_container.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/component-container/src/atomic_container.rs rename to tee-worker/common/core-primitives/component-container/src/atomic_container.rs diff --git a/tee-worker/bitacross/core-primitives/component-container/src/component_container.rs b/tee-worker/common/core-primitives/component-container/src/component_container.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/component-container/src/component_container.rs rename to tee-worker/common/core-primitives/component-container/src/component_container.rs diff --git a/tee-worker/bitacross/core-primitives/component-container/src/error.rs b/tee-worker/common/core-primitives/component-container/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/component-container/src/error.rs rename to tee-worker/common/core-primitives/component-container/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/component-container/src/lib.rs b/tee-worker/common/core-primitives/component-container/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/component-container/src/lib.rs rename to tee-worker/common/core-primitives/component-container/src/lib.rs diff --git a/tee-worker/common/core-primitives/enclave-metrics/Cargo.toml b/tee-worker/common/core-primitives/enclave-metrics/Cargo.toml new file mode 100644 index 0000000000..da443b7078 --- /dev/null +++ b/tee-worker/common/core-primitives/enclave-metrics/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "itp-enclave-metrics" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["full"] } +litentry-primitives = { workspace = true } +sgx_tstd = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "litentry-primitives/std", +] +sgx = [ + "sgx_tstd", + "litentry-primitives/sgx", +] diff --git a/tee-worker/identity/core-primitives/enclave-metrics/src/lib.rs b/tee-worker/common/core-primitives/enclave-metrics/src/lib.rs similarity index 89% rename from tee-worker/identity/core-primitives/enclave-metrics/src/lib.rs rename to tee-worker/common/core-primitives/enclave-metrics/src/lib.rs index 0d311aa2d7..68f55825dc 100644 --- a/tee-worker/identity/core-primitives/enclave-metrics/src/lib.rs +++ b/tee-worker/common/core-primitives/enclave-metrics/src/lib.rs @@ -26,12 +26,12 @@ extern crate sgx_tstd as std; use codec::{Decode, Encode}; use core::time::Duration; -use lc_stf_task_sender::RequestType; -use litentry_primitives::Assertion; +use litentry_primitives::{Assertion, RequestType}; use std::{boxed::Box, string::String}; #[derive(Encode, Decode, Debug)] pub enum EnclaveMetric { + // identity SetSidechainBlockHeight(u64), TopPoolSizeSet(u64), TopPoolSizeIncrement, @@ -51,4 +51,9 @@ pub enum EnclaveMetric { ParentchainEventProcessed(String), DynamicAssertionSaveTime(Duration), DynamicAssertionGetTime(Duration), + // bitacross + Musig2CeremonyStarted, + Musig2CeremonyFailed, + Musig2CeremonyTimedout(u8), + Musig2CeremonyDuration(Duration), } diff --git a/tee-worker/common/core-primitives/extrinsics-factory/Cargo.toml b/tee-worker/common/core-primitives/extrinsics-factory/Cargo.toml new file mode 100644 index 0000000000..2de446487b --- /dev/null +++ b/tee-worker/common/core-primitives/extrinsics-factory/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "itp-extrinsics-factory" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } +substrate-api-client = { workspace = true } + +itp-node-api = { workspace = true } +itp-nonce-cache = { workspace = true } +itp-types = { workspace = true } + +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } + +[features] +default = ["std"] +std = [ + "itp-node-api/std", + "itp-nonce-cache/std", + "itp-types/std", + "log/std", + "substrate-api-client/std", + "thiserror", + "codec/std", + "sp-core/std", + "sp-runtime/std", +] +sgx = [ + "itp-node-api/sgx", + "itp-nonce-cache/sgx", + "sgx_tstd", + "thiserror_sgx", +] +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/extrinsics-factory/src/error.rs b/tee-worker/common/core-primitives/extrinsics-factory/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/extrinsics-factory/src/error.rs rename to tee-worker/common/core-primitives/extrinsics-factory/src/error.rs diff --git a/tee-worker/identity/core-primitives/extrinsics-factory/src/lib.rs b/tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs similarity index 100% rename from tee-worker/identity/core-primitives/extrinsics-factory/src/lib.rs rename to tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs diff --git a/tee-worker/identity/core-primitives/extrinsics-factory/src/mock.rs b/tee-worker/common/core-primitives/extrinsics-factory/src/mock.rs similarity index 100% rename from tee-worker/identity/core-primitives/extrinsics-factory/src/mock.rs rename to tee-worker/common/core-primitives/extrinsics-factory/src/mock.rs diff --git a/tee-worker/bitacross/core-primitives/settings/Cargo.toml b/tee-worker/common/core-primitives/hashing/Cargo.toml similarity index 63% rename from tee-worker/bitacross/core-primitives/settings/Cargo.toml rename to tee-worker/common/core-primitives/hashing/Cargo.toml index 592d57d444..9041ce7134 100644 --- a/tee-worker/bitacross/core-primitives/settings/Cargo.toml +++ b/tee-worker/common/core-primitives/hashing/Cargo.toml @@ -1,11 +1,14 @@ [package] -name = "itp-settings" +name = "itp-hashing" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] +sp-core = { workspace = true } [features] -development = [] -offchain-worker = [] +default = ["std"] +std = [ + "sp-core/std", +] diff --git a/tee-worker/bitacross/core-primitives/hashing/src/lib.rs b/tee-worker/common/core-primitives/hashing/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/hashing/src/lib.rs rename to tee-worker/common/core-primitives/hashing/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/hashing/src/std_hash.rs b/tee-worker/common/core-primitives/hashing/src/std_hash.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/hashing/src/std_hash.rs rename to tee-worker/common/core-primitives/hashing/src/std_hash.rs diff --git a/tee-worker/common/core-primitives/import-queue/Cargo.toml b/tee-worker/common/core-primitives/import-queue/Cargo.toml new file mode 100644 index 0000000000..256cc7fd2d --- /dev/null +++ b/tee-worker/common/core-primitives/import-queue/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "itp-import-queue" +version = "0.8.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/import-queue/src/error.rs b/tee-worker/common/core-primitives/import-queue/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/import-queue/src/error.rs rename to tee-worker/common/core-primitives/import-queue/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/import-queue/src/import_queue.rs b/tee-worker/common/core-primitives/import-queue/src/import_queue.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/import-queue/src/import_queue.rs rename to tee-worker/common/core-primitives/import-queue/src/import_queue.rs diff --git a/tee-worker/bitacross/core-primitives/import-queue/src/lib.rs b/tee-worker/common/core-primitives/import-queue/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/import-queue/src/lib.rs rename to tee-worker/common/core-primitives/import-queue/src/lib.rs diff --git a/tee-worker/identity/core-primitives/hashing/Cargo.toml b/tee-worker/common/core-primitives/networking-utils/Cargo.toml similarity index 56% rename from tee-worker/identity/core-primitives/hashing/Cargo.toml rename to tee-worker/common/core-primitives/networking-utils/Cargo.toml index e7a04918a1..91495e00a2 100644 --- a/tee-worker/identity/core-primitives/hashing/Cargo.toml +++ b/tee-worker/common/core-primitives/networking-utils/Cargo.toml @@ -1,13 +1,15 @@ [package] -name = "itp-hashing" +name = "itp-networking-utils" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sgx_tstd = { workspace = true, optional = true } [features] default = ["std"] std = [] +sgx = [ + "sgx_tstd", +] diff --git a/tee-worker/bitacross/core-primitives/networking-utils/src/lib.rs b/tee-worker/common/core-primitives/networking-utils/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/networking-utils/src/lib.rs rename to tee-worker/common/core-primitives/networking-utils/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/networking-utils/src/ports.rs b/tee-worker/common/core-primitives/networking-utils/src/ports.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/networking-utils/src/ports.rs rename to tee-worker/common/core-primitives/networking-utils/src/ports.rs diff --git a/tee-worker/identity/core-primitives/node-api/Cargo.toml b/tee-worker/common/core-primitives/node-api/Cargo.toml similarity index 56% rename from tee-worker/identity/core-primitives/node-api/Cargo.toml rename to tee-worker/common/core-primitives/node-api/Cargo.toml index c5ba3c9763..cde4ffe64d 100644 --- a/tee-worker/identity/core-primitives/node-api/Cargo.toml +++ b/tee-worker/common/core-primitives/node-api/Cargo.toml @@ -5,11 +5,11 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sp-consensus-grandpa = { workspace = true, features = ["std"] } +sp-runtime = { workspace = true, features = ["std"] } +substrate-api-client = { workspace = true, features = ["std"] } + +itp-api-client-types = { workspace = true, features = ["std"] } +itp-types = { workspace = true, features = ["std"] } + +[features] +# used for unit testing only! +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/account.rs b/tee-worker/common/core-primitives/node-api/api-client-extensions/src/account.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/account.rs rename to tee-worker/common/core-primitives/node-api/api-client-extensions/src/account.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/chain.rs b/tee-worker/common/core-primitives/node-api/api-client-extensions/src/chain.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/chain.rs rename to tee-worker/common/core-primitives/node-api/api-client-extensions/src/chain.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/lib.rs b/tee-worker/common/core-primitives/node-api/api-client-extensions/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/lib.rs rename to tee-worker/common/core-primitives/node-api/api-client-extensions/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs b/tee-worker/common/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs rename to tee-worker/common/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs diff --git a/tee-worker/identity/core-primitives/node-api/api-client-types/Cargo.toml b/tee-worker/common/core-primitives/node-api/api-client-types/Cargo.toml similarity index 58% rename from tee-worker/identity/core-primitives/node-api/api-client-types/Cargo.toml rename to tee-worker/common/core-primitives/node-api/api-client-types/Cargo.toml index 9155bfac40..6f64d6ca97 100644 --- a/tee-worker/identity/core-primitives/node-api/api-client-types/Cargo.toml +++ b/tee-worker/common/core-primitives/node-api/api-client-types/Cargo.toml @@ -5,8 +5,8 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG '] +edition = "2021" + +[dependencies] +itp-api-client-types = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } +thiserror = { workspace = true } diff --git a/tee-worker/bitacross/core-primitives/node-api/factory/src/lib.rs b/tee-worker/common/core-primitives/node-api/factory/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/factory/src/lib.rs rename to tee-worker/common/core-primitives/node-api/factory/src/lib.rs diff --git a/tee-worker/common/core-primitives/node-api/metadata-provider/Cargo.toml b/tee-worker/common/core-primitives/node-api/metadata-provider/Cargo.toml new file mode 100644 index 0000000000..2cc5b2d17b --- /dev/null +++ b/tee-worker/common/core-primitives/node-api/metadata-provider/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "itp-node-api-metadata-provider" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +itp-node-api-metadata = { workspace = true } +itp-stf-primitives = { workspace = true } + +[features] +default = ["std"] +std = [ + "thiserror", + "itp-stf-primitives/std", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] +# used for unit testing only! +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata-provider/src/error.rs b/tee-worker/common/core-primitives/node-api/metadata-provider/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata-provider/src/error.rs rename to tee-worker/common/core-primitives/node-api/metadata-provider/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata-provider/src/lib.rs b/tee-worker/common/core-primitives/node-api/metadata-provider/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata-provider/src/lib.rs rename to tee-worker/common/core-primitives/node-api/metadata-provider/src/lib.rs diff --git a/tee-worker/common/core-primitives/node-api/metadata/Cargo.toml b/tee-worker/common/core-primitives/node-api/metadata/Cargo.toml new file mode 100644 index 0000000000..9a20703e4b --- /dev/null +++ b/tee-worker/common/core-primitives/node-api/metadata/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "itp-node-api-metadata" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +itp-api-client-types = { workspace = true } +itp-stf-primitives = { workspace = true } +sp-core = { workspace = true } +sp-version = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "itp-api-client-types/std", + "sp-core/std", + "sp-version/std", + "itp-stf-primitives/std", +] + +# used for unit testing only! +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/error.rs b/tee-worker/common/core-primitives/node-api/metadata/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/error.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/error.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/lib.rs b/tee-worker/common/core-primitives/node-api/metadata/src/lib.rs similarity index 95% rename from tee-worker/identity/core-primitives/node-api/metadata/src/lib.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/lib.rs index 1705582b90..352decf8ca 100644 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/lib.rs +++ b/tee-worker/common/core-primitives/node-api/metadata/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use crate::{ - error::Result, pallet_balances::BalancesCallIndexes, + error::Result, pallet_balances::BalancesCallIndexes, pallet_bitacross::BitAcrossCallIndexes, pallet_evm_assertion::EvmAssertionsCallIndexes, pallet_imp::IMPCallIndexes, pallet_proxy::ProxyCallIndexes, pallet_system::SystemConstants, pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, @@ -34,6 +34,7 @@ pub use itp_api_client_types::{Metadata, MetadataError}; pub mod error; pub mod pallet_balances; +pub mod pallet_bitacross; pub mod pallet_evm_assertion; pub mod pallet_imp; pub mod pallet_proxy; @@ -58,6 +59,7 @@ pub trait NodeMetadataTrait: + BalancesCallIndexes + TimestampCallIndexes + EvmAssertionsCallIndexes + + BitAcrossCallIndexes { } @@ -70,7 +72,8 @@ impl< + ProxyCallIndexes + BalancesCallIndexes + TimestampCallIndexes - + EvmAssertionsCallIndexes, + + EvmAssertionsCallIndexes + + BitAcrossCallIndexes, > NodeMetadataTrait for T { } diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/metadata_mocks.rs b/tee-worker/common/core-primitives/node-api/metadata/src/metadata_mocks.rs similarity index 88% rename from tee-worker/identity/core-primitives/node-api/metadata/src/metadata_mocks.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/metadata_mocks.rs index adf13c8cf8..6fb986da21 100644 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/metadata_mocks.rs +++ b/tee-worker/common/core-primitives/node-api/metadata/src/metadata_mocks.rs @@ -16,7 +16,7 @@ */ use crate::{ - error::Result, pallet_balances::BalancesCallIndexes, + error::Result, pallet_balances::BalancesCallIndexes, pallet_bitacross::BitAcrossCallIndexes, pallet_evm_assertion::EvmAssertionsCallIndexes, pallet_imp::IMPCallIndexes, pallet_proxy::ProxyCallIndexes, pallet_system::SystemConstants, pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, @@ -88,6 +88,13 @@ pub struct NodeMetadataMock { timestamp_set: u8, runtime_spec_version: u32, runtime_transaction_version: u32, + + bitacross_module: u8, + bitacross_add_relayer: u8, + bitacross_remove_relayer: u8, + btc_wallet_generated: u8, + eth_wallet_generated: u8, + ton_wallet_generated: u8, } impl NodeMetadataMock { @@ -143,6 +150,13 @@ impl NodeMetadataMock { timestamp_set: 0, runtime_spec_version: 25, runtime_transaction_version: 4, + + bitacross_module: 69u8, + bitacross_add_relayer: 0u8, + bitacross_remove_relayer: 1u8, + btc_wallet_generated: 2u8, + eth_wallet_generated: 3u8, + ton_wallet_generated: 4u8, } } } @@ -295,6 +309,28 @@ impl BalancesCallIndexes for NodeMetadataMock { } } +impl BitAcrossCallIndexes for NodeMetadataMock { + fn add_relayer_call_indexes(&self) -> Result<[u8; 2]> { + Ok([self.bitacross_module, self.bitacross_add_relayer]) + } + + fn remove_relayer_call_indexes(&self) -> Result<[u8; 2]> { + Ok([self.bitacross_module, self.bitacross_remove_relayer]) + } + + fn btc_wallet_generated_indexes(&self) -> Result<[u8; 2]> { + Ok([self.bitacross_module, self.btc_wallet_generated]) + } + + fn eth_wallet_generated_indexes(&self) -> Result<[u8; 2]> { + Ok([self.bitacross_module, self.eth_wallet_generated]) + } + + fn ton_wallet_generated_indexes(&self) -> Result<[u8; 2]> { + Ok([self.bitacross_module, self.ton_wallet_generated]) + } +} + impl TimestampCallIndexes for NodeMetadataMock { fn timestamp_set_call_indexes(&self) -> Result<[u8; 2]> { Ok([self.timestamp_module, self.timestamp_set]) diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_balances.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_balances.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_balances.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_balances.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_bitacross.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_bitacross.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_bitacross.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_bitacross.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_evm_assertion.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_evm_assertion.rs similarity index 100% rename from tee-worker/identity/core-primitives/node-api/metadata/src/pallet_evm_assertion.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_evm_assertion.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_imp.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_imp.rs similarity index 100% rename from tee-worker/identity/core-primitives/node-api/metadata/src/pallet_imp.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_imp.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_proxy.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_proxy.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_proxy.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_proxy.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_sidechain.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_sidechain.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_sidechain.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_sidechain.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_system.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_system.rs similarity index 100% rename from tee-worker/identity/core-primitives/node-api/metadata/src/pallet_system.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_system.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_teebag.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_teebag.rs similarity index 100% rename from tee-worker/identity/core-primitives/node-api/metadata/src/pallet_teebag.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_teebag.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_timestamp.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_timestamp.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_timestamp.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_timestamp.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_utility.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_utility.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/pallet_utility.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_utility.rs diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_vcmp.rs b/tee-worker/common/core-primitives/node-api/metadata/src/pallet_vcmp.rs similarity index 100% rename from tee-worker/identity/core-primitives/node-api/metadata/src/pallet_vcmp.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/pallet_vcmp.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/metadata/src/runtime_call.rs b/tee-worker/common/core-primitives/node-api/metadata/src/runtime_call.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/metadata/src/runtime_call.rs rename to tee-worker/common/core-primitives/node-api/metadata/src/runtime_call.rs diff --git a/tee-worker/bitacross/core-primitives/node-api/src/lib.rs b/tee-worker/common/core-primitives/node-api/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/node-api/src/lib.rs rename to tee-worker/common/core-primitives/node-api/src/lib.rs diff --git a/tee-worker/common/core-primitives/nonce-cache/Cargo.toml b/tee-worker/common/core-primitives/nonce-cache/Cargo.toml new file mode 100644 index 0000000000..a2098d9e4a --- /dev/null +++ b/tee-worker/common/core-primitives/nonce-cache/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "itp-nonce-cache" +version = "0.8.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/nonce-cache/src/error.rs b/tee-worker/common/core-primitives/nonce-cache/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/nonce-cache/src/error.rs rename to tee-worker/common/core-primitives/nonce-cache/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/nonce-cache/src/lib.rs b/tee-worker/common/core-primitives/nonce-cache/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/nonce-cache/src/lib.rs rename to tee-worker/common/core-primitives/nonce-cache/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/nonce-cache/src/nonce_cache.rs b/tee-worker/common/core-primitives/nonce-cache/src/nonce_cache.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/nonce-cache/src/nonce_cache.rs rename to tee-worker/common/core-primitives/nonce-cache/src/nonce_cache.rs diff --git a/tee-worker/common/core-primitives/ocall-api/Cargo.toml b/tee-worker/common/core-primitives/ocall-api/Cargo.toml new file mode 100644 index 0000000000..655bedbc9a --- /dev/null +++ b/tee-worker/common/core-primitives/ocall-api/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "itp-ocall-api" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } + +sgx_types = { workspace = true } + +sp-core = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +itp-storage = { workspace = true } +itp-types = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", + "itp-storage/std", + "itp-types/std", +] diff --git a/tee-worker/identity/core-primitives/ocall-api/src/lib.rs b/tee-worker/common/core-primitives/ocall-api/src/lib.rs similarity index 100% rename from tee-worker/identity/core-primitives/ocall-api/src/lib.rs rename to tee-worker/common/core-primitives/ocall-api/src/lib.rs diff --git a/tee-worker/common/core-primitives/primitives-cache/Cargo.toml b/tee-worker/common/core-primitives/primitives-cache/Cargo.toml new file mode 100644 index 0000000000..f1a8e4b898 --- /dev/null +++ b/tee-worker/common/core-primitives/primitives-cache/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "itp-primitives-cache" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +lazy_static = { workspace = true } +sgx_tstd = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/primitives-cache/src/error.rs b/tee-worker/common/core-primitives/primitives-cache/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/primitives-cache/src/error.rs rename to tee-worker/common/core-primitives/primitives-cache/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/primitives-cache/src/lib.rs b/tee-worker/common/core-primitives/primitives-cache/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/primitives-cache/src/lib.rs rename to tee-worker/common/core-primitives/primitives-cache/src/lib.rs diff --git a/tee-worker/identity/core-primitives/primitives-cache/src/primitives_cache.rs b/tee-worker/common/core-primitives/primitives-cache/src/primitives_cache.rs similarity index 100% rename from tee-worker/identity/core-primitives/primitives-cache/src/primitives_cache.rs rename to tee-worker/common/core-primitives/primitives-cache/src/primitives_cache.rs diff --git a/tee-worker/common/core-primitives/rpc/Cargo.toml b/tee-worker/common/core-primitives/rpc/Cargo.toml new file mode 100644 index 0000000000..99a5ababb7 --- /dev/null +++ b/tee-worker/common/core-primitives/rpc/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "itp-rpc" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +itp-types = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +sgx_tstd = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "itp-types/std", + "serde/std", + "serde_json/std", +] +sgx = [ + "sgx_tstd", +] diff --git a/tee-worker/identity/core-primitives/rpc/src/lib.rs b/tee-worker/common/core-primitives/rpc/src/lib.rs similarity index 100% rename from tee-worker/identity/core-primitives/rpc/src/lib.rs rename to tee-worker/common/core-primitives/rpc/src/lib.rs diff --git a/tee-worker/identity/core-primitives/settings/Cargo.toml b/tee-worker/common/core-primitives/settings/Cargo.toml similarity index 76% rename from tee-worker/identity/core-primitives/settings/Cargo.toml rename to tee-worker/common/core-primitives/settings/Cargo.toml index 6cf475f504..a2b7fbe6a4 100644 --- a/tee-worker/identity/core-primitives/settings/Cargo.toml +++ b/tee-worker/common/core-primitives/settings/Cargo.toml @@ -5,7 +5,7 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG '] +edition = "2021" + +[dependencies] +frame-system = { workspace = true } +pallet-balances = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } + +[features] +default = ["std"] +std = [ + "frame-system/std", + "pallet-balances/std", + "sp-core/std", + "sp-runtime/std", +] diff --git a/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/constants.rs b/tee-worker/common/core-primitives/sgx-runtime-primitives/src/constants.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/constants.rs rename to tee-worker/common/core-primitives/sgx-runtime-primitives/src/constants.rs diff --git a/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/lib.rs b/tee-worker/common/core-primitives/sgx-runtime-primitives/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/lib.rs rename to tee-worker/common/core-primitives/sgx-runtime-primitives/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/types.rs b/tee-worker/common/core-primitives/sgx-runtime-primitives/src/types.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx-runtime-primitives/src/types.rs rename to tee-worker/common/core-primitives/sgx-runtime-primitives/src/types.rs diff --git a/tee-worker/common/core-primitives/sgx/crypto/Cargo.toml b/tee-worker/common/core-primitives/sgx/crypto/Cargo.toml new file mode 100644 index 0000000000..2aa3a3b5a4 --- /dev/null +++ b/tee-worker/common/core-primitives/sgx/crypto/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "itp-sgx-crypto" +version = "0.1.0" +edition = "2021" + +[dependencies] +aes = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +hex = { workspace = true } +k256 = { workspace = true, features = ["ecdsa-core", "schnorr", "alloc"] } +log = { workspace = true } +ofb = { workspace = true } +secp256k1 = { workspace = true, features = ["alloc", "recovery"] } +serde_json = { workspace = true, optional = true } + +serde_json_sgx = { workspace = true, optional = true } +sgx_crypto_helper = { workspace = true } +sgx_rand = { workspace = true, optional = true } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +sp-core = { workspace = true } + +itp-sgx-io = { workspace = true } +itp-sgx-temp-dir = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "log/std", + "itp-sgx-io/std", + "sp-core/std", + "serde_json/std", + "sgx_crypto_helper/default", +] +sgx = [ + "sgx_crypto_helper/mesalock_sgx", + "sgx_tstd", + "sgx_rand", + "itp-sgx-io/sgx", + "serde_json_sgx", +] +mocks = [] +test = [ + "mocks", + "sgx", + "itp-sgx-temp-dir", +] diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/aes.rs b/tee-worker/common/core-primitives/sgx/crypto/src/aes.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/aes.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/aes.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/ecdsa.rs b/tee-worker/common/core-primitives/sgx/crypto/src/ecdsa.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/ecdsa.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/ecdsa.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/ed25519.rs b/tee-worker/common/core-primitives/sgx/crypto/src/ed25519.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/ed25519.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/ed25519.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/ed25519_derivation.rs b/tee-worker/common/core-primitives/sgx/crypto/src/ed25519_derivation.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/ed25519_derivation.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/ed25519_derivation.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/error.rs b/tee-worker/common/core-primitives/sgx/crypto/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/error.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/key_repository.rs b/tee-worker/common/core-primitives/sgx/crypto/src/key_repository.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/key_repository.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/key_repository.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/lib.rs b/tee-worker/common/core-primitives/sgx/crypto/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/lib.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/mocks.rs b/tee-worker/common/core-primitives/sgx/crypto/src/mocks.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/mocks.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/mocks.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/rsa3072.rs b/tee-worker/common/core-primitives/sgx/crypto/src/rsa3072.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/rsa3072.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/rsa3072.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/schnorr.rs b/tee-worker/common/core-primitives/sgx/crypto/src/schnorr.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/schnorr.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/schnorr.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/crypto/src/traits.rs b/tee-worker/common/core-primitives/sgx/crypto/src/traits.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/crypto/src/traits.rs rename to tee-worker/common/core-primitives/sgx/crypto/src/traits.rs diff --git a/tee-worker/common/core-primitives/sgx/io/Cargo.toml b/tee-worker/common/core-primitives/sgx/io/Cargo.toml new file mode 100644 index 0000000000..f3c54e0d5d --- /dev/null +++ b/tee-worker/common/core-primitives/sgx/io/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "itp-sgx-io" +version = "0.8.0" +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, features = ["untrusted_fs"], optional = true } + +[features] +default = ["std"] +std = [] +sgx = [ + "sgx_tstd", +] diff --git a/tee-worker/bitacross/core-primitives/sgx/io/src/lib.rs b/tee-worker/common/core-primitives/sgx/io/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/io/src/lib.rs rename to tee-worker/common/core-primitives/sgx/io/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/temp-dir/Cargo.toml b/tee-worker/common/core-primitives/sgx/temp-dir/Cargo.toml similarity index 52% rename from tee-worker/bitacross/core-primitives/sgx/temp-dir/Cargo.toml rename to tee-worker/common/core-primitives/sgx/temp-dir/Cargo.toml index c86fcafbd1..f782f877c8 100644 --- a/tee-worker/bitacross/core-primitives/sgx/temp-dir/Cargo.toml +++ b/tee-worker/common/core-primitives/sgx/temp-dir/Cargo.toml @@ -4,10 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +lazy_static = { workspace = true } +sgx_tstd = { workspace = true, optional = true } [dev-dependencies.safe-lock] version = "^0.1" diff --git a/tee-worker/bitacross/core-primitives/sgx/temp-dir/src/lib.rs b/tee-worker/common/core-primitives/sgx/temp-dir/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/temp-dir/src/lib.rs rename to tee-worker/common/core-primitives/sgx/temp-dir/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/sgx/temp-dir/src/test.rs b/tee-worker/common/core-primitives/sgx/temp-dir/src/test.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/sgx/temp-dir/src/test.rs rename to tee-worker/common/core-primitives/sgx/temp-dir/src/test.rs diff --git a/tee-worker/common/core-primitives/stf-interface/Cargo.toml b/tee-worker/common/core-primitives/stf-interface/Cargo.toml new file mode 100644 index 0000000000..a46749521d --- /dev/null +++ b/tee-worker/common/core-primitives/stf-interface/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "itp-stf-interface" +version = "0.8.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } + +itp-node-api-metadata = { workspace = true, features = ["mocks"] } +itp-node-api-metadata-provider = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } + +[features] +default = ["std"] +std = [ + "itp-node-api-metadata/std", + "itp-node-api-metadata-provider/std", + "itp-stf-primitives/std", + "itp-types/std", +] +sgx = [] +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/lib.rs b/tee-worker/common/core-primitives/stf-interface/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/lib.rs rename to tee-worker/common/core-primitives/stf-interface/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/mocks.rs b/tee-worker/common/core-primitives/stf-interface/src/mocks.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/mocks.rs rename to tee-worker/common/core-primitives/stf-interface/src/mocks.rs diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/parentchain_pallet.rs b/tee-worker/common/core-primitives/stf-interface/src/parentchain_pallet.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/parentchain_pallet.rs rename to tee-worker/common/core-primitives/stf-interface/src/parentchain_pallet.rs diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/runtime_upgrade.rs b/tee-worker/common/core-primitives/stf-interface/src/runtime_upgrade.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/runtime_upgrade.rs rename to tee-worker/common/core-primitives/stf-interface/src/runtime_upgrade.rs diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/sudo_pallet.rs b/tee-worker/common/core-primitives/stf-interface/src/sudo_pallet.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/sudo_pallet.rs rename to tee-worker/common/core-primitives/stf-interface/src/sudo_pallet.rs diff --git a/tee-worker/bitacross/core-primitives/stf-interface/src/system_pallet.rs b/tee-worker/common/core-primitives/stf-interface/src/system_pallet.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-interface/src/system_pallet.rs rename to tee-worker/common/core-primitives/stf-interface/src/system_pallet.rs diff --git a/tee-worker/common/core-primitives/stf-primitives/Cargo.toml b/tee-worker/common/core-primitives/stf-primitives/Cargo.toml new file mode 100644 index 0000000000..9f0f9062ab --- /dev/null +++ b/tee-worker/common/core-primitives/stf-primitives/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "itp-stf-primitives" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } + +itp-sgx-runtime-primitives = { workspace = true } + +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +# litentry +litentry-primitives = { workspace = true } + +[features] +default = ["std"] +std = [ + # crates.io + "codec/std", + # substrate + "sp-core/std", + "sp-std/std", + "sp-runtime/std", + "itp-sgx-runtime-primitives/std", + # litentry + "litentry-primitives/std", +] diff --git a/tee-worker/identity/core-primitives/stf-primitives/src/error.rs b/tee-worker/common/core-primitives/stf-primitives/src/error.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-primitives/src/error.rs rename to tee-worker/common/core-primitives/stf-primitives/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/stf-primitives/src/lib.rs b/tee-worker/common/core-primitives/stf-primitives/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-primitives/src/lib.rs rename to tee-worker/common/core-primitives/stf-primitives/src/lib.rs diff --git a/tee-worker/identity/core-primitives/stf-primitives/src/traits.rs b/tee-worker/common/core-primitives/stf-primitives/src/traits.rs similarity index 90% rename from tee-worker/identity/core-primitives/stf-primitives/src/traits.rs rename to tee-worker/common/core-primitives/stf-primitives/src/traits.rs index 404db9a5ff..f86e7260d8 100644 --- a/tee-worker/identity/core-primitives/stf-primitives/src/traits.rs +++ b/tee-worker/common/core-primitives/stf-primitives/src/traits.rs @@ -57,7 +57,7 @@ pub trait PoolTransactionValidation { /// Trait to be implemented on the executor to serve helper methods of the executor /// to the `IndirectDispatch` implementation. -pub trait IndirectExecutor +pub trait IndirectExecutor where TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, { @@ -78,4 +78,16 @@ where trusted_call: &TC, shard: &ShardIdentifier, ) -> Result; + + fn get_relayer_registry_updater(&self) -> &RRU { + unimplemented!() + } + + fn get_signer_registry_updater(&self) -> &SRU { + unimplemented!() + } + + fn get_enclave_registry_updater(&self) -> &ERU { + unimplemented!() + } } diff --git a/tee-worker/bitacross/core-primitives/stf-primitives/src/types.rs b/tee-worker/common/core-primitives/stf-primitives/src/types.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-primitives/src/types.rs rename to tee-worker/common/core-primitives/stf-primitives/src/types.rs diff --git a/tee-worker/common/core-primitives/stf-state-handler/Cargo.toml b/tee-worker/common/core-primitives/stf-state-handler/Cargo.toml new file mode 100644 index 0000000000..7d7e2f6203 --- /dev/null +++ b/tee-worker/common/core-primitives/stf-state-handler/Cargo.toml @@ -0,0 +1,67 @@ +[package] +name = "itp-stf-state-handler" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +itp-hashing = { workspace = true, default-features = false } +itp-settings = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-sgx-io = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-state-observer = { workspace = true } +itp-time-utils = { workspace = true } +itp-types = { workspace = true } + +# for tests +itp-sgx-temp-dir = { workspace = true, optional = true } + +rust-base58_sgx = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +rust-base58 = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } + +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } + +[dev-dependencies] +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } +itp-stf-state-observer = { workspace = true, features = ["std", "mocks"] } +itp-hashing = { workspace = true, features = ["std"] } + +[features] +default = ["std"] +std = [ + "rust-base58", + "itp-sgx-crypto/std", + "itp-sgx-externalities/std", + "itp-sgx-io/std", + "itp-stf-interface/std", + "itp-stf-state-observer/std", + "itp-time-utils/std", + "itp-types/std", + "thiserror", + "log/std", +] +sgx = [ + "sgx_tstd", + "rust-base58_sgx", + "itp-sgx-crypto/sgx", + "itp-sgx-externalities/sgx", + "itp-sgx-io/sgx", + "itp-stf-state-observer/sgx", + "itp-time-utils/sgx", + "thiserror_sgx", +] +test = [ + "itp-sgx-crypto/mocks", + "itp-stf-interface/mocks", + "itp-sgx-temp-dir", +] diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/error.rs b/tee-worker/common/core-primitives/stf-state-handler/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/error.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/error.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/file_io.rs b/tee-worker/common/core-primitives/stf-state-handler/src/file_io.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/file_io.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/file_io.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/handle_state.rs b/tee-worker/common/core-primitives/stf-state-handler/src/handle_state.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/handle_state.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/handle_state.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs b/tee-worker/common/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/in_memory_state_file_io.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/lib.rs b/tee-worker/common/core-primitives/stf-state-handler/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/lib.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/query_shard_state.rs b/tee-worker/common/core-primitives/stf-state-handler/src/query_shard_state.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/query_shard_state.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/query_shard_state.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/state_handler.rs b/tee-worker/common/core-primitives/stf-state-handler/src/state_handler.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/state_handler.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/state_handler.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_initializer.rs b/tee-worker/common/core-primitives/stf-state-handler/src/state_initializer.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/state_initializer.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/state_initializer.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs b/tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_repository.rs b/tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_repository.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_repository.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_repository.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs b/tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/mod.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/mod.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/mod.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/mod.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/mocks/versioned_state_access_mock.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mod.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/mod.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/test/mod.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/mod.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-handler/src/test/sgx_tests.rs b/tee-worker/common/core-primitives/stf-state-handler/src/test/sgx_tests.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-handler/src/test/sgx_tests.rs rename to tee-worker/common/core-primitives/stf-state-handler/src/test/sgx_tests.rs diff --git a/tee-worker/common/core-primitives/stf-state-observer/Cargo.toml b/tee-worker/common/core-primitives/stf-state-observer/Cargo.toml new file mode 100644 index 0000000000..effab9dbeb --- /dev/null +++ b/tee-worker/common/core-primitives/stf-state-observer/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "itp-stf-state-observer" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +itp-types = { workspace = true } +sgx_tstd = { workspace = true, optional = true } + +log = { workspace = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "itp-types/std", + "log/std", + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] +mocks = [] diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/src/error.rs b/tee-worker/common/core-primitives/stf-state-observer/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-observer/src/error.rs rename to tee-worker/common/core-primitives/stf-state-observer/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/src/lib.rs b/tee-worker/common/core-primitives/stf-state-observer/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-observer/src/lib.rs rename to tee-worker/common/core-primitives/stf-state-observer/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/src/mock.rs b/tee-worker/common/core-primitives/stf-state-observer/src/mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-observer/src/mock.rs rename to tee-worker/common/core-primitives/stf-state-observer/src/mock.rs diff --git a/tee-worker/identity/core-primitives/stf-state-observer/src/state_observer.rs b/tee-worker/common/core-primitives/stf-state-observer/src/state_observer.rs similarity index 100% rename from tee-worker/identity/core-primitives/stf-state-observer/src/state_observer.rs rename to tee-worker/common/core-primitives/stf-state-observer/src/state_observer.rs diff --git a/tee-worker/bitacross/core-primitives/stf-state-observer/src/traits.rs b/tee-worker/common/core-primitives/stf-state-observer/src/traits.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/stf-state-observer/src/traits.rs rename to tee-worker/common/core-primitives/stf-state-observer/src/traits.rs diff --git a/tee-worker/common/core-primitives/storage/Cargo.toml b/tee-worker/common/core-primitives/storage/Cargo.toml new file mode 100644 index 0000000000..d3c48d6e05 --- /dev/null +++ b/tee-worker/common/core-primitives/storage/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "itp-storage" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["chain-error"] } +derive_more = { workspace = true } +frame-metadata = { workspace = true } +hash-db = { workspace = true } + +sgx_tstd = { workspace = true, optional = true } + +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +frame-support = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +sp-trie = { workspace = true } + +itp-types = { workspace = true } + +[dev-dependencies] +sp-state-machine = { workspace = true, features = ["std"] } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-metadata/std", + "frame-support/std", + "hash-db/std", + "itp-types/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", + "sp-trie/std", + "thiserror", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", +] +test = [] diff --git a/tee-worker/bitacross/core-primitives/storage/src/error.rs b/tee-worker/common/core-primitives/storage/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/storage/src/error.rs rename to tee-worker/common/core-primitives/storage/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/storage/src/keys.rs b/tee-worker/common/core-primitives/storage/src/keys.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/storage/src/keys.rs rename to tee-worker/common/core-primitives/storage/src/keys.rs diff --git a/tee-worker/bitacross/core-primitives/storage/src/lib.rs b/tee-worker/common/core-primitives/storage/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/storage/src/lib.rs rename to tee-worker/common/core-primitives/storage/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/storage/src/proof.rs b/tee-worker/common/core-primitives/storage/src/proof.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/storage/src/proof.rs rename to tee-worker/common/core-primitives/storage/src/proof.rs diff --git a/tee-worker/bitacross/core-primitives/storage/src/verify_storage_proof.rs b/tee-worker/common/core-primitives/storage/src/verify_storage_proof.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/storage/src/verify_storage_proof.rs rename to tee-worker/common/core-primitives/storage/src/verify_storage_proof.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/environmental/Cargo.toml b/tee-worker/common/core-primitives/substrate-sgx/environmental/Cargo.toml similarity index 69% rename from tee-worker/bitacross/core-primitives/substrate-sgx/environmental/Cargo.toml rename to tee-worker/common/core-primitives/substrate-sgx/environmental/Cargo.toml index 354aa878a6..d3b974540f 100644 --- a/tee-worker/bitacross/core-primitives/substrate-sgx/environmental/Cargo.toml +++ b/tee-worker/common/core-primitives/substrate-sgx/environmental/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" edition = "2021" [dependencies] -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["thread"] } +sgx_tstd = { workspace = true, features = ["thread"], optional = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/environmental/src/lib.rs b/tee-worker/common/core-primitives/substrate-sgx/environmental/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/environmental/src/lib.rs rename to tee-worker/common/core-primitives/substrate-sgx/environmental/src/lib.rs diff --git a/tee-worker/common/core-primitives/substrate-sgx/externalities/Cargo.toml b/tee-worker/common/core-primitives/substrate-sgx/externalities/Cargo.toml new file mode 100644 index 0000000000..9ea2584c27 --- /dev/null +++ b/tee-worker/common/core-primitives/substrate-sgx/externalities/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "itp-sgx-externalities" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG and Parity Technologies '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["chain-error"] } +derive_more = { workspace = true } +log = { workspace = true } +postcard = { workspace = true } +serde = { workspace = true } + +sgx_tstd = { workspace = true, features = ["untrusted_fs", "net", "backtrace"], optional = true } + +sp-core = { workspace = true } + +environmental = { path = "../environmental", default-features = false } +itp-hashing = { workspace = true } + +[dev-dependencies] +itp-storage = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "environmental/std", + "itp-hashing/std", + "log/std", + "postcard/use-std", + "serde/std", + "itp-storage/std", + "sp-core/std", +] +sgx = [ + "sgx_tstd", + "environmental/sgx", +] diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/bypass.rs b/tee-worker/common/core-primitives/substrate-sgx/externalities/src/bypass.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/bypass.rs rename to tee-worker/common/core-primitives/substrate-sgx/externalities/src/bypass.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/codec_impl.rs b/tee-worker/common/core-primitives/substrate-sgx/externalities/src/codec_impl.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/codec_impl.rs rename to tee-worker/common/core-primitives/substrate-sgx/externalities/src/codec_impl.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/lib.rs b/tee-worker/common/core-primitives/substrate-sgx/externalities/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/lib.rs rename to tee-worker/common/core-primitives/substrate-sgx/externalities/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/scope_limited.rs b/tee-worker/common/core-primitives/substrate-sgx/externalities/src/scope_limited.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/scope_limited.rs rename to tee-worker/common/core-primitives/substrate-sgx/externalities/src/scope_limited.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/vectorize.rs b/tee-worker/common/core-primitives/substrate-sgx/externalities/src/vectorize.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/substrate-sgx/externalities/src/vectorize.rs rename to tee-worker/common/core-primitives/substrate-sgx/externalities/src/vectorize.rs diff --git a/tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/Cargo.toml b/tee-worker/common/core-primitives/substrate-sgx/sp-io/Cargo.toml similarity index 53% rename from tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/Cargo.toml rename to tee-worker/common/core-primitives/substrate-sgx/sp-io/Cargo.toml index 0600c8a4b6..597fe0058c 100644 --- a/tee-worker/bitacross/core-primitives/substrate-sgx/sp-io/Cargo.toml +++ b/tee-worker/common/core-primitives/substrate-sgx/sp-io/Cargo.toml @@ -6,15 +6,14 @@ edition = "2021" license = "Apache-2.0" [dependencies] -codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false } -libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +libsecp256k1 = { workspace = true, features = ["static-context"] } +log = { workspace = true } -itp-sgx-externalities = { default-features = false, path = "../externalities" } -sgx_tstd = { optional = true, features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } +itp-sgx-externalities = { path = "../externalities", default-features = false } +sgx_tstd = { workspace = true, features = ["untrusted_fs", "net", "backtrace"], optional = true } -# Substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-core = { workspace = true, features = ["full_crypto"] } [features] default = ["std"] diff --git a/tee-worker/identity/core-primitives/substrate-sgx/sp-io/src/lib.rs b/tee-worker/common/core-primitives/substrate-sgx/sp-io/src/lib.rs similarity index 100% rename from tee-worker/identity/core-primitives/substrate-sgx/sp-io/src/lib.rs rename to tee-worker/common/core-primitives/substrate-sgx/sp-io/src/lib.rs diff --git a/tee-worker/common/core-primitives/test/Cargo.toml b/tee-worker/common/core-primitives/test/Cargo.toml new file mode 100644 index 0000000000..a738a22b15 --- /dev/null +++ b/tee-worker/common/core-primitives/test/Cargo.toml @@ -0,0 +1,68 @@ +[package] +name = "itp-test" +version = "0.1.0" +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sgx_crypto_helper = { workspace = true } + +jsonrpc-core_sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +sp-core = { workspace = true } +sp-io = { path = "../substrate-sgx/sp-io", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +itp-node-api = { workspace = true } +itp-node-api-metadata-provider = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } + +hex = { workspace = true } +lc-teebag-storage = { workspace = true } +litentry-primitives = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "itp-node-api-metadata-provider/std", + "itp-node-api/std", + "itp-ocall-api/std", + "itp-sgx-crypto/std", + "itp-sgx-externalities/std", + "itp-stf-interface/std", + "itp-stf-primitives/std", + "itp-stf-state-handler/std", + "itp-storage/std", + "itp-types/std", + "log/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "litentry-primitives/std", + "lc-teebag-storage/std", + "sgx_crypto_helper/default", +] +sgx = [ + "itp-node-api/sgx", + "itp-node-api-metadata-provider/sgx", + "itp-sgx-crypto/sgx", + "itp-sgx-externalities/sgx", + "itp-stf-state-handler/sgx", + "jsonrpc-core_sgx", + "sgx_tstd", + "litentry-primitives/sgx", + "sgx_crypto_helper/mesalock_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/test/src/lib.rs b/tee-worker/common/core-primitives/test/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/test/src/lib.rs rename to tee-worker/common/core-primitives/test/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/handle_state_mock.rs b/tee-worker/common/core-primitives/test/src/mock/handle_state_mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/test/src/mock/handle_state_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/handle_state_mock.rs diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/metrics_ocall_mock.rs b/tee-worker/common/core-primitives/test/src/mock/metrics_ocall_mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/test/src/mock/metrics_ocall_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/metrics_ocall_mock.rs diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/mod.rs b/tee-worker/common/core-primitives/test/src/mock/mod.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/test/src/mock/mod.rs rename to tee-worker/common/core-primitives/test/src/mock/mod.rs diff --git a/tee-worker/identity/core-primitives/test/src/mock/onchain_mock.rs b/tee-worker/common/core-primitives/test/src/mock/onchain_mock.rs similarity index 100% rename from tee-worker/identity/core-primitives/test/src/mock/onchain_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/onchain_mock.rs diff --git a/tee-worker/bitacross/core-primitives/test/src/mock/shielding_crypto_mock.rs b/tee-worker/common/core-primitives/test/src/mock/shielding_crypto_mock.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/test/src/mock/shielding_crypto_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/shielding_crypto_mock.rs diff --git a/tee-worker/identity/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs b/tee-worker/common/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs similarity index 100% rename from tee-worker/identity/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/sidechain_ocall_api_mock.rs diff --git a/tee-worker/identity/core-primitives/test/src/mock/stf_mock.rs b/tee-worker/common/core-primitives/test/src/mock/stf_mock.rs similarity index 100% rename from tee-worker/identity/core-primitives/test/src/mock/stf_mock.rs rename to tee-worker/common/core-primitives/test/src/mock/stf_mock.rs diff --git a/tee-worker/common/core-primitives/time-utils/Cargo.toml b/tee-worker/common/core-primitives/time-utils/Cargo.toml new file mode 100644 index 0000000000..4d18baf231 --- /dev/null +++ b/tee-worker/common/core-primitives/time-utils/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "itp-time-utils" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +chrono = { workspace = true, optional = true } +chrono_sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, optional = true } + +[features] +default = ["std"] +std = [ + "chrono", +] +sgx = [ + "sgx_tstd", + "chrono_sgx", +] diff --git a/tee-worker/bitacross/core-primitives/time-utils/src/lib.rs b/tee-worker/common/core-primitives/time-utils/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/time-utils/src/lib.rs rename to tee-worker/common/core-primitives/time-utils/src/lib.rs diff --git a/tee-worker/common/core-primitives/types/Cargo.toml b/tee-worker/common/core-primitives/types/Cargo.toml new file mode 100644 index 0000000000..e23a1eca85 --- /dev/null +++ b/tee-worker/common/core-primitives/types/Cargo.toml @@ -0,0 +1,48 @@ +[package] +name = "itp-types" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +homepage = 'https://litentry.com/' +repository = 'https://github.com/litentry/litentry-parachain' +license = "Apache-2.0" +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true } +serde = { workspace = true } + +itp-sgx-crypto = { workspace = true } +itp-sgx-runtime-primitives = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-utils = { workspace = true } + +substrate-api-client = { workspace = true } + +frame-system = { workspace = true } +pallet-balances = { workspace = true } +sp-consensus-grandpa = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +litentry-primitives = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "itp-sgx-crypto/std", + "itp-sgx-runtime-primitives/std", + "itp-stf-primitives/std", + "itp-utils/std", + "substrate-api-client/std", + "frame-system/std", + "pallet-balances/std", + "serde/std", + "sp-std/std", + "sp-core/std", + "sp-runtime/std", + "sp-consensus-grandpa/std", + "litentry-primitives/std", +] +test = [] diff --git a/tee-worker/identity/core-primitives/types/src/lib.rs b/tee-worker/common/core-primitives/types/src/lib.rs similarity index 98% rename from tee-worker/identity/core-primitives/types/src/lib.rs rename to tee-worker/common/core-primitives/types/src/lib.rs index a4d58a2969..b224381f63 100644 --- a/tee-worker/identity/core-primitives/types/src/lib.rs +++ b/tee-worker/common/core-primitives/types/src/lib.rs @@ -25,7 +25,9 @@ use litentry_primitives::decl_rsa_request; use sp_std::{boxed::Box, fmt::Debug, vec::Vec}; pub mod parentchain; +pub mod sidechain; pub mod storage; +pub use sidechain::SidechainBlockHash; pub use itp_sgx_runtime_primitives::types::*; pub use litentry_primitives::{ @@ -90,6 +92,8 @@ pub enum DirectRequestStatus { /// Direct request could not be executed #[codec(index = 2)] Error, + #[codec(index = 3)] + Processing(H256), } #[derive(Debug, Clone, PartialEq, Encode, Decode, Eq)] diff --git a/tee-worker/identity/core-primitives/types/src/parentchain/events.rs b/tee-worker/common/core-primitives/types/src/parentchain/events.rs similarity index 70% rename from tee-worker/identity/core-primitives/types/src/parentchain/events.rs rename to tee-worker/common/core-primitives/types/src/parentchain/events.rs index f6b40d1339..0442e2094d 100644 --- a/tee-worker/identity/core-primitives/types/src/parentchain/events.rs +++ b/tee-worker/common/core-primitives/types/src/parentchain/events.rs @@ -6,7 +6,7 @@ use crate::{ use codec::{Decode, Encode}; use core::fmt::Debug; use itp_utils::{hex::ToHexPrefixed, stringify::account_id_to_string}; - +use litentry_primitives::{Address32, Identity}; use sp_core::H160; use substrate_api_client::ac_node_api::StaticEvent; @@ -100,7 +100,46 @@ impl StaticEvent for EnclaveUnauthorized { const EVENT: &'static str = "EnclaveUnauthorized"; } -// IdentityManagement events +#[derive(Encode, Decode, Debug)] +pub struct EnclaveAdded { + pub who: Address32, + pub worker_type: WorkerType, + pub url: Vec, +} + +impl core::fmt::Display for EnclaveAdded { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + let message = format!( + "EnclaveAdded :: who: {:?}, worker_type: {:?}, url: {:?}", + self.who, self.worker_type, self.url + ); + write!(f, "{}", message) + } +} + +impl StaticEvent for EnclaveAdded { + const PALLET: &'static str = "Teebag"; + const EVENT: &'static str = "EnclaveAdded"; +} + +#[derive(Encode, Decode, Debug)] +pub struct EnclaveRemoved { + pub who: Address32, +} + +impl core::fmt::Display for EnclaveRemoved { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + let message = format!("EnclaveRemoved :: who: {:?}", self.who); + write!(f, "{}", message) + } +} + +impl StaticEvent for EnclaveRemoved { + const PALLET: &'static str = "Teebag"; + const EVENT: &'static str = "EnclaveRemoved"; +} + +// Identity-worker events #[derive(Encode, Decode, Debug)] pub struct LinkIdentityRequested { @@ -244,3 +283,66 @@ impl StaticEvent for AssertionCreated { const PALLET: &'static str = "EvmAssertions"; const EVENT: &'static str = "AssertionCreated"; } + +// Bitacross pallet events + +#[derive(Encode, Decode, Debug)] +pub struct RelayerAdded { + pub who: Identity, +} + +impl core::fmt::Display for RelayerAdded { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(account_id) = self.who.to_account_id() { + let message = format!("RelayerAdded :: account_id: {:?}", account_id); + write!(f, "{}", message) + } else { + write!(f, "RelayerAdded :: account_id: None") + } + } +} + +impl StaticEvent for RelayerAdded { + const PALLET: &'static str = "Bitacross"; + const EVENT: &'static str = "RelayerAdded"; +} + +#[derive(Encode, Decode, Debug)] +pub struct RelayerRemoved { + pub who: Identity, +} + +impl core::fmt::Display for RelayerRemoved { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(account_id) = self.who.to_account_id() { + let message = format!("RelayerRemoved :: account_id: {:?}", account_id); + write!(f, "{}", message) + } else { + write!(f, "RelayerRemoved :: account_id: None") + } + } +} + +impl StaticEvent for RelayerRemoved { + const PALLET: &'static str = "Bitacross"; + const EVENT: &'static str = "RelayerRemoved"; +} + +#[derive(Encode, Decode, Debug)] +pub struct BtcWalletGenerated { + pub pub_key: [u8; 33], + pub account_id: AccountId, +} + +impl core::fmt::Display for BtcWalletGenerated { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + let account_id = account_id_to_string::(&self.account_id); + let message = format!("BtcWalletGenerated :: account_id: {:?}", account_id); + write!(f, "{}", message) + } +} + +impl StaticEvent for BtcWalletGenerated { + const PALLET: &'static str = "Bitacross"; + const EVENT: &'static str = "BtcWalletGenerated"; +} diff --git a/tee-worker/identity/core-primitives/types/src/parentchain/mod.rs b/tee-worker/common/core-primitives/types/src/parentchain/mod.rs similarity index 64% rename from tee-worker/identity/core-primitives/types/src/parentchain/mod.rs rename to tee-worker/common/core-primitives/types/src/parentchain/mod.rs index 723127eafa..6c4d9135c7 100644 --- a/tee-worker/identity/core-primitives/types/src/parentchain/mod.rs +++ b/tee-worker/common/core-primitives/types/src/parentchain/mod.rs @@ -17,14 +17,11 @@ pub mod events; -use crate::{parentchain::events::AssertionCreated, OpaqueCall}; +use crate::{parentchain::events::AssertionCreated, OpaqueCall, ShardIdentifier}; use alloc::vec::Vec; use codec::{Decode, Encode}; use core::fmt::Debug; -use events::{ - ActivateIdentityRequested, DeactivateIdentityRequested, EnclaveUnauthorized, - LinkIdentityRequested, OpaqueTaskPosted, VCRequested, -}; +use events::*; use itp_stf_primitives::traits::{IndirectExecutor, TrustedCallVerification}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -116,6 +113,16 @@ pub trait FilterEvents { fn get_parentchain_block_proccessed_events( &self, ) -> Result, Self::Error>; + + fn get_relayer_added_events(&self) -> Result, Self::Error>; + + fn get_relayers_removed_events(&self) -> Result, Self::Error>; + + fn get_enclave_added_events(&self) -> Result, Self::Error>; + + fn get_enclave_removed_events(&self) -> Result, Self::Error>; + + fn get_btc_wallet_generated_events(&self) -> Result, Self::Error>; } #[derive(Debug)] @@ -126,16 +133,18 @@ pub enum ExtrinsicStatus { pub type ProcessedEventsArtifacts = (Vec, Vec, Vec); -pub trait HandleParentchainEvents +pub trait HandleParentchainEvents where - Executor: IndirectExecutor, + Executor: IndirectExecutor, TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, { + type Output; + fn handle_events( &self, executor: &Executor, events: impl FilterEvents, - ) -> Result; + ) -> Result; } #[derive(Debug)] @@ -149,6 +158,11 @@ pub enum ParentchainEventProcessingError { OpaqueTaskPostedFailure, AssertionCreatedFailure, ParentchainBlockProcessedFailure, + RelayerAddFailure, + RelayerRemoveFailure, + EnclaveAddFailure, + EnclaveRemoveFailure, + BtcWalletGeneratedFailure, } impl core::fmt::Display for ParentchainEventProcessingError { @@ -172,6 +186,16 @@ impl core::fmt::Display for ParentchainEventProcessingError { "Parentchain Event Processing Error: AssertionCreatedFailure", ParentchainEventProcessingError::ParentchainBlockProcessedFailure => "Parentchain Event Processing Error: ParentchainBlockProcessedFailure", + ParentchainEventProcessingError::RelayerAddFailure => + "Parentchain Event Processing Error: RelayerAddFailure", + ParentchainEventProcessingError::RelayerRemoveFailure => + "Parentchain Event Processing Error: RelayerRemoveFailure", + ParentchainEventProcessingError::EnclaveAddFailure => + "Parentchain Event Processing Error: EnclaveAddFailure", + ParentchainEventProcessingError::EnclaveRemoveFailure => + "Parentchain Event Processing Error: EnclaveRemoveFailure", + ParentchainEventProcessingError::BtcWalletGeneratedFailure => + "Parentchain Event Processing Error: BtcWalletGeneratedFailure", }; write!(f, "{}", message) } @@ -234,3 +258,80 @@ impl ParentchainCall { } } } + +// Moved from `itc_light_client::light_client_init_params` to de-couple deps +use sp_consensus_grandpa::AuthorityList; + +#[derive(Encode, Decode, Clone)] +pub struct GrandpaParams
{ + pub genesis_header: Header, + pub authorities: AuthorityList, + pub authority_proof: Vec>, +} + +impl
GrandpaParams
{ + pub fn new( + genesis_header: Header, + authorities: AuthorityList, + authority_proof: Vec>, + ) -> Self { + Self { genesis_header, authorities, authority_proof } + } +} + +#[derive(Encode, Decode, Clone)] +pub struct SimpleParams
{ + pub genesis_header: Header, +} + +impl
SimpleParams
{ + pub fn new(genesis_header: Header) -> Self { + Self { genesis_header } + } +} + +// Moved from `itc_parent::primitives` +use sp_runtime::traits::Block; + +pub type ParachainBlock = crate::Block; +pub type SolochainBlock = crate::Block; +pub type HeaderFor = ::Header; +pub type SolochainHeader = HeaderFor; +pub type ParachainHeader = HeaderFor; +pub type SolochainParams = GrandpaParams; +pub type ParachainParams = SimpleParams; + +/// Initialization primitives, used by both service and enclave. +/// Allows to use a single E-call for the initialization of different parentchain types. +#[derive(Encode, Decode, Clone)] +pub enum ParentchainInitParams { + Solochain { id: ParentchainId, shard: ShardIdentifier, params: SolochainParams }, + Parachain { id: ParentchainId, shard: ShardIdentifier, params: ParachainParams }, +} + +impl ParentchainInitParams { + pub fn id(&self) -> &ParentchainId { + match self { + Self::Solochain { id, .. } => id, + Self::Parachain { id, .. } => id, + } + } + pub fn is_solochain(&self) -> bool { + matches!(self, Self::Solochain { .. }) + } + pub fn is_parachain(&self) -> bool { + matches!(self, Self::Parachain { .. }) + } +} + +impl From<(ParentchainId, ShardIdentifier, SolochainParams)> for ParentchainInitParams { + fn from(value: (ParentchainId, ShardIdentifier, SolochainParams)) -> Self { + Self::Solochain { id: value.0, shard: value.1, params: value.2 } + } +} + +impl From<(ParentchainId, ShardIdentifier, ParachainParams)> for ParentchainInitParams { + fn from(value: (ParentchainId, ShardIdentifier, ParachainParams)) -> Self { + Self::Parachain { id: value.0, shard: value.1, params: value.2 } + } +} diff --git a/tee-worker/identity/core-primitives/stf-interface/src/runtime_upgrade.rs b/tee-worker/common/core-primitives/types/src/sidechain.rs similarity index 84% rename from tee-worker/identity/core-primitives/stf-interface/src/runtime_upgrade.rs rename to tee-worker/common/core-primitives/types/src/sidechain.rs index 649ba34ca5..511d91662b 100644 --- a/tee-worker/identity/core-primitives/stf-interface/src/runtime_upgrade.rs +++ b/tee-worker/common/core-primitives/types/src/sidechain.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Litentry. If not, see . -pub trait RuntimeUpgradeInterface { - type Error; - - fn on_runtime_upgrade(state: &mut State) -> Result<(), Self::Error>; -} +// To avoid introducing its_primitives in core-primitives/top-pool +use crate::H256; +pub type SidechainBlockHash = H256; diff --git a/tee-worker/bitacross/core-primitives/types/src/storage.rs b/tee-worker/common/core-primitives/types/src/storage.rs similarity index 98% rename from tee-worker/bitacross/core-primitives/types/src/storage.rs rename to tee-worker/common/core-primitives/types/src/storage.rs index b30f1d6f21..c38e46ab1a 100644 --- a/tee-worker/bitacross/core-primitives/types/src/storage.rs +++ b/tee-worker/common/core-primitives/types/src/storage.rs @@ -33,7 +33,6 @@ pub struct StorageEntryVerified { pub value: Option, } -#[cfg(feature = "test")] impl StorageEntryVerified { pub fn new(key: Vec, value: Option) -> Self { Self { key, value } diff --git a/tee-worker/identity/core-primitives/utils/Cargo.toml b/tee-worker/common/core-primitives/utils/Cargo.toml similarity index 57% rename from tee-worker/identity/core-primitives/utils/Cargo.toml rename to tee-worker/common/core-primitives/utils/Cargo.toml index 5fb370797f..cff40a1f94 100644 --- a/tee-worker/identity/core-primitives/utils/Cargo.toml +++ b/tee-worker/common/core-primitives/utils/Cargo.toml @@ -8,9 +8,9 @@ license = "Apache-2.0" edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -litentry-hex-utils = { path = "../../../../common/utils/hex", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +litentry-hex-utils = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/core-primitives/utils/src/buffer.rs b/tee-worker/common/core-primitives/utils/src/buffer.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/buffer.rs rename to tee-worker/common/core-primitives/utils/src/buffer.rs diff --git a/tee-worker/bitacross/core-primitives/utils/src/error.rs b/tee-worker/common/core-primitives/utils/src/error.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/error.rs rename to tee-worker/common/core-primitives/utils/src/error.rs diff --git a/tee-worker/bitacross/core-primitives/utils/src/hex.rs b/tee-worker/common/core-primitives/utils/src/hex.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/hex.rs rename to tee-worker/common/core-primitives/utils/src/hex.rs diff --git a/tee-worker/bitacross/core-primitives/utils/src/hex_display.rs b/tee-worker/common/core-primitives/utils/src/hex_display.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/hex_display.rs rename to tee-worker/common/core-primitives/utils/src/hex_display.rs diff --git a/tee-worker/bitacross/core-primitives/utils/src/lib.rs b/tee-worker/common/core-primitives/utils/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/lib.rs rename to tee-worker/common/core-primitives/utils/src/lib.rs diff --git a/tee-worker/bitacross/core-primitives/utils/src/stringify.rs b/tee-worker/common/core-primitives/utils/src/stringify.rs similarity index 100% rename from tee-worker/bitacross/core-primitives/utils/src/stringify.rs rename to tee-worker/common/core-primitives/utils/src/stringify.rs diff --git a/tee-worker/common/core/parentchain/light-client/Cargo.toml b/tee-worker/common/core/parentchain/light-client/Cargo.toml new file mode 100644 index 0000000000..d88cbd952c --- /dev/null +++ b/tee-worker/common/core/parentchain/light-client/Cargo.toml @@ -0,0 +1,67 @@ +[package] +name = "itc-parentchain-light-client" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["chain-error"] } +finality-grandpa = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true, optional = true } + +sgx_tstd = { workspace = true, features = ["untrusted_fs"], optional = true } +sgx_types = { workspace = true } +thiserror_sgx = { workspace = true, optional = true } + +itp-ocall-api = { workspace = true } +itp-sgx-io = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } + +sp-consensus-grandpa = { workspace = true } +sp-runtime = { workspace = true } + +# test & mock dependencies +itc-parentchain-test = { workspace = true, optional = true } +# We can't really make this optional due to feature flag complexities. +itp-sgx-temp-dir = { workspace = true } +itp-test = { workspace = true, features = ["sgx"], optional = true } + +[dev-dependencies] +itc-parentchain-test = { workspace = true, features = ["std"] } +itp-test = { workspace = true, features = ["std"] } +itp-sgx-temp-dir = { workspace = true, features = ["std"] } + +[features] +default = ["std"] +std = [ + "codec/std", + "log/std", + "finality-grandpa/std", + "thiserror", + + # substrate deps + "sp-consensus-grandpa/std", + "sp-runtime/std", + + # local deps + "itp-ocall-api/std", + "itp-storage/std", + "itp-sgx-io/std", + "itp-types/std", + # mock deps + "itp-sgx-temp-dir/std", +] +sgx = [ + "sgx_tstd", + "thiserror_sgx", + "itp-sgx-io/sgx", + "itp-storage/sgx", + "itp-sgx-temp-dir/sgx", +] +mocks = [ + "itc-parentchain-test", +] + +test = ["mocks", "itp-test"] diff --git a/tee-worker/identity/core/parentchain/light-client/src/concurrent_access.rs b/tee-worker/common/core/parentchain/light-client/src/concurrent_access.rs similarity index 100% rename from tee-worker/identity/core/parentchain/light-client/src/concurrent_access.rs rename to tee-worker/common/core/parentchain/light-client/src/concurrent_access.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/error.rs b/tee-worker/common/core/parentchain/light-client/src/error.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/error.rs rename to tee-worker/common/core/parentchain/light-client/src/error.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/finality.rs b/tee-worker/common/core/parentchain/light-client/src/finality.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/finality.rs rename to tee-worker/common/core/parentchain/light-client/src/finality.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/io.rs b/tee-worker/common/core/parentchain/light-client/src/io.rs similarity index 97% rename from tee-worker/bitacross/core/parentchain/light-client/src/io.rs rename to tee-worker/common/core/parentchain/light-client/src/io.rs index 64a7771aaa..a494f225c7 100644 --- a/tee-worker/bitacross/core/parentchain/light-client/src/io.rs +++ b/tee-worker/common/core/parentchain/light-client/src/io.rs @@ -18,7 +18,6 @@ use crate::{ error::{Error, Result}, finality::{Finality, GrandpaFinality, ParachainFinality}, - light_client_init_params::{GrandpaParams, SimpleParams}, light_validation::{check_validator_set_proof, LightValidation}, state::RelayState, LightClientSealing, LightClientState, LightValidationState, NumberFor, Validator, @@ -27,7 +26,7 @@ use codec::{Decode, Encode}; use core::{fmt::Debug, marker::PhantomData}; use itp_ocall_api::EnclaveOnChainOCallApi; use itp_sgx_io::{seal, unseal}; -use itp_types::parentchain::{IdentifyParentchain, ParentchainId}; +use itp_types::parentchain::{GrandpaParams, IdentifyParentchain, ParentchainId, SimpleParams}; use log::*; use sp_runtime::traits::{Block, Header}; use std::{ @@ -370,14 +369,11 @@ where #[cfg(feature = "test")] pub mod sgx_tests { use super::{read_or_init_parachain_validator, Arc, LightClientStateSeal, RelayState}; - use crate::{ - light_client_init_params::SimpleParams, LightClientSealing, LightClientState, - LightValidationState, - }; + use crate::{LightClientSealing, LightClientState, LightValidationState}; use itc_parentchain_test::{Block, Header, ParentchainHeaderBuilder}; use itp_sgx_temp_dir::TempDir; use itp_test::mock::onchain_mock::OnchainMock; - use itp_types::parentchain::ParentchainId; + use itp_types::parentchain::{ParentchainId, SimpleParams}; use sp_runtime::OpaqueExtrinsic; type TestBlock = Block; diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/justification.rs b/tee-worker/common/core/parentchain/light-client/src/justification.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/justification.rs rename to tee-worker/common/core/parentchain/light-client/src/justification.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/lib.rs b/tee-worker/common/core/parentchain/light-client/src/lib.rs similarity index 99% rename from tee-worker/bitacross/core/parentchain/light-client/src/lib.rs rename to tee-worker/common/core/parentchain/light-client/src/lib.rs index 64b46c480f..4a4c0496dc 100644 --- a/tee-worker/bitacross/core/parentchain/light-client/src/lib.rs +++ b/tee-worker/common/core/parentchain/light-client/src/lib.rs @@ -45,7 +45,6 @@ pub mod concurrent_access; pub mod error; pub mod finality; pub mod justification; -pub mod light_client_init_params; pub mod light_validation; pub mod light_validation_state; pub mod state; diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/light_validation.rs b/tee-worker/common/core/parentchain/light-client/src/light_validation.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/light_validation.rs rename to tee-worker/common/core/parentchain/light-client/src/light_validation.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/light_validation_state.rs b/tee-worker/common/core/parentchain/light-client/src/light_validation_state.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/light_validation_state.rs rename to tee-worker/common/core/parentchain/light-client/src/light_validation_state.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/mocks/mod.rs b/tee-worker/common/core/parentchain/light-client/src/mocks/mod.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/mocks/mod.rs rename to tee-worker/common/core/parentchain/light-client/src/mocks/mod.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_access_mock.rs b/tee-worker/common/core/parentchain/light-client/src/mocks/validator_access_mock.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_access_mock.rs rename to tee-worker/common/core/parentchain/light-client/src/mocks/validator_access_mock.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_mock.rs b/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_mock.rs rename to tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_mock_seal.rs b/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock_seal.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/mocks/validator_mock_seal.rs rename to tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock_seal.rs diff --git a/tee-worker/bitacross/core/parentchain/light-client/src/state.rs b/tee-worker/common/core/parentchain/light-client/src/state.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/light-client/src/state.rs rename to tee-worker/common/core/parentchain/light-client/src/state.rs diff --git a/tee-worker/bitacross/core/parentchain/test/Cargo.toml b/tee-worker/common/core/parentchain/test/Cargo.toml similarity index 65% rename from tee-worker/bitacross/core/parentchain/test/Cargo.toml rename to tee-worker/common/core/parentchain/test/Cargo.toml index e1bc4a6859..c5989483ea 100644 --- a/tee-worker/bitacross/core/parentchain/test/Cargo.toml +++ b/tee-worker/common/core/parentchain/test/Cargo.toml @@ -8,8 +8,8 @@ license = "Apache-2.0" edition = "2021" [dependencies] -itp-types = { path = "../../../core-primitives/types", default-features = false } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +itp-types = { workspace = true } +sp-runtime = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/bitacross/core/parentchain/test/src/lib.rs b/tee-worker/common/core/parentchain/test/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/test/src/lib.rs rename to tee-worker/common/core/parentchain/test/src/lib.rs diff --git a/tee-worker/bitacross/core/parentchain/test/src/parentchain_block_builder.rs b/tee-worker/common/core/parentchain/test/src/parentchain_block_builder.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/test/src/parentchain_block_builder.rs rename to tee-worker/common/core/parentchain/test/src/parentchain_block_builder.rs diff --git a/tee-worker/bitacross/core/parentchain/test/src/parentchain_header_builder.rs b/tee-worker/common/core/parentchain/test/src/parentchain_header_builder.rs similarity index 100% rename from tee-worker/bitacross/core/parentchain/test/src/parentchain_header_builder.rs rename to tee-worker/common/core/parentchain/test/src/parentchain_header_builder.rs diff --git a/tee-worker/common/core/rest-client/Cargo.toml b/tee-worker/common/core/rest-client/Cargo.toml new file mode 100644 index 0000000000..badd685bf8 --- /dev/null +++ b/tee-worker/common/core/rest-client/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "itc-rest-client" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +http = { workspace = true, optional = true } +http_req = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } + +# sgx dependencies +http-sgx = { workspace = true, optional = true } +http_req-sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } + +base64 = { workspace = true } +log = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } + +[features] +default = ["std"] +std = [ + "http", + "http_req", + "thiserror", + "base64/std", + "serde/std", + "serde_json/std", + "log/std", + "url/std", +] +sgx = [ + "http-sgx", + "http_req-sgx", + "sgx_tstd", + "thiserror_sgx", +] diff --git a/tee-worker/bitacross/core/rest-client/src/error.rs b/tee-worker/common/core/rest-client/src/error.rs similarity index 100% rename from tee-worker/bitacross/core/rest-client/src/error.rs rename to tee-worker/common/core/rest-client/src/error.rs diff --git a/tee-worker/bitacross/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem b/tee-worker/common/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem similarity index 100% rename from tee-worker/bitacross/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem rename to tee-worker/common/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem diff --git a/tee-worker/bitacross/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem b/tee-worker/common/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem similarity index 100% rename from tee-worker/bitacross/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem rename to tee-worker/common/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem diff --git a/tee-worker/bitacross/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem b/tee-worker/common/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem similarity index 100% rename from tee-worker/bitacross/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem rename to tee-worker/common/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem diff --git a/tee-worker/identity/core/rest-client/src/http_client.rs b/tee-worker/common/core/rest-client/src/http_client.rs similarity index 100% rename from tee-worker/identity/core/rest-client/src/http_client.rs rename to tee-worker/common/core/rest-client/src/http_client.rs diff --git a/tee-worker/identity/core/rest-client/src/lib.rs b/tee-worker/common/core/rest-client/src/lib.rs similarity index 100% rename from tee-worker/identity/core/rest-client/src/lib.rs rename to tee-worker/common/core/rest-client/src/lib.rs diff --git a/tee-worker/identity/core/rest-client/src/mocks/http_client_mock.rs b/tee-worker/common/core/rest-client/src/mocks/http_client_mock.rs similarity index 100% rename from tee-worker/identity/core/rest-client/src/mocks/http_client_mock.rs rename to tee-worker/common/core/rest-client/src/mocks/http_client_mock.rs diff --git a/tee-worker/bitacross/core/rest-client/src/mocks/mod.rs b/tee-worker/common/core/rest-client/src/mocks/mod.rs similarity index 100% rename from tee-worker/bitacross/core/rest-client/src/mocks/mod.rs rename to tee-worker/common/core/rest-client/src/mocks/mod.rs diff --git a/tee-worker/identity/core/rest-client/src/rest_client.rs b/tee-worker/common/core/rest-client/src/rest_client.rs similarity index 100% rename from tee-worker/identity/core/rest-client/src/rest_client.rs rename to tee-worker/common/core/rest-client/src/rest_client.rs diff --git a/tee-worker/common/core/rpc-client/Cargo.toml b/tee-worker/common/core/rpc-client/Cargo.toml new file mode 100644 index 0000000000..6a9619f987 --- /dev/null +++ b/tee-worker/common/core/rpc-client/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "itc-rpc-client" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +base58 = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true, features = ["std"] } +log = { workspace = true, features = ["std"] } +openssl = "0.10" +parking_lot = "0.12.1" +serde_json = { workspace = true, features = ["std"] } +sgx_crypto_helper = { workspace = true, features = ["ucrypto_help"] } +thiserror = { workspace = true } +url = { version = "2.0.0" } +ws = { version = "0.9.1", features = ["ssl"] } + +frame-metadata = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } + +itp-api-client-types = { workspace = true, features = ["std"] } +itp-rpc = { workspace = true, features = ["std"] } +itp-stf-primitives = { workspace = true, features = ["std"] } +itp-types = { workspace = true, features = ["std"] } +itp-utils = { workspace = true, features = ["std"] } +litentry-primitives = { workspace = true } + +[dev-dependencies] +env_logger = { workspace = true } +itc-tls-websocket-server = { workspace = true, features = ["mocks"] } +itp-networking-utils = { workspace = true, features = ["std"] } +rustls = { workspace = true, features = ["dangerous_configuration"] } diff --git a/tee-worker/bitacross/core/rpc-client/src/direct_client.rs b/tee-worker/common/core/rpc-client/src/direct_client.rs similarity index 87% rename from tee-worker/bitacross/core/rpc-client/src/direct_client.rs rename to tee-worker/common/core/rpc-client/src/direct_client.rs index d7acedb944..024e637444 100644 --- a/tee-worker/bitacross/core/rpc-client/src/direct_client.rs +++ b/tee-worker/common/core/rpc-client/src/direct_client.rs @@ -22,12 +22,12 @@ use crate::ws_client::{WsClient, WsClientControl}; use base58::ToBase58; use codec::{Decode, Encode}; use frame_metadata::RuntimeMetadataPrefixed; -use ita_stf::Getter; use itp_api_client_types::Metadata; use itp_rpc::{Id, RpcRequest, RpcResponse, RpcReturnValue}; -use itp_stf_primitives::types::{AccountId, ShardIdentifier}; -use itp_types::{DirectRequestStatus, MrEnclave, RsaRequest}; +use itp_stf_primitives::types::ShardIdentifier; +use itp_types::{DirectRequestStatus, MrEnclave}; use itp_utils::{FromHexPrefixed, ToHexPrefixed}; +use litentry_primitives::Identity; use log::*; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use std::{ @@ -54,12 +54,14 @@ pub trait DirectApi { fn get_untrusted_worker_url(&self) -> Result; fn get_state_metadata(&self) -> Result; fn send(&self, request: &str) -> Result<()>; + fn import_sidechain_blocks(&self, blocks_encoded: String) -> Result<()>; + /// Close any open websocket connection. fn close(&self) -> Result<()>; // litentry fn get_state_metadata_raw(&self) -> Result; - fn get_next_nonce(&self, shard: &ShardIdentifier, account: &AccountId) -> Result; + fn get_next_nonce(&self, shard: &ShardIdentifier, account: &Identity) -> Result; fn get_state_mrenclave(&self) -> Result; } @@ -68,46 +70,6 @@ impl DirectClient { Self { url, web_socket_control: Default::default() } } - // litentry: moved from `cli/src/trusted_operation.rs` as it's more widely used - pub fn get_state(&self, shard: ShardIdentifier, getter: &Getter) -> Option> { - // Compose jsonrpc call. - let data = RsaRequest::new(shard, getter.encode()); - let rpc_method = "state_executeGetter".to_owned(); - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - rpc_method, - vec![data.to_hex()], - ) - .unwrap(); - - let rpc_response_str = self.get(&jsonrpc_call).unwrap(); - - // Decode RPC response. - let rpc_response: RpcResponse = serde_json::from_str(&rpc_response_str).ok()?; - let rpc_return_value = RpcReturnValue::from_hex(&rpc_response.result) - // Replace with `inspect_err` once it's stable. - .map_err(|e| { - error!("Failed to decode RpcReturnValue: {:?}", e); - e - }) - .ok()?; - - if rpc_return_value.status == DirectRequestStatus::Error { - println!("[Error] {}", String::decode(&mut rpc_return_value.value.as_slice()).unwrap()); - return None - } - - let maybe_state = Option::decode(&mut rpc_return_value.value.as_slice()) - // Replace with `inspect_err` once it's stable. - .map_err(|e| { - error!("Failed to decode return value: {:?}", e); - e - }) - .ok()?; - - maybe_state - } - // common helper function for `get_state_metadata` and `get_state_metadata_raw` fn get_metadata_internal(&self) -> Result { let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( @@ -218,6 +180,16 @@ impl DirectApi for DirectClient { self.web_socket_control.send(request) } + fn import_sidechain_blocks(&self, blocks_encoded: String) -> Result<()> { + let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( + Id::Text("1".to_string()), + "sidechain_importBlock".to_owned(), + vec![blocks_encoded], + )?; + self.get(&jsonrpc_call)?; + Ok(()) + } + fn close(&self) -> Result<()> { self.web_socket_control.close_connection() } @@ -229,7 +201,7 @@ impl DirectApi for DirectClient { serde_json::to_string(&rpc_response).map_err(|e| Error::Custom(Box::new(e))) } - fn get_next_nonce(&self, shard: &ShardIdentifier, account: &AccountId) -> Result { + fn get_next_nonce(&self, shard: &ShardIdentifier, account: &Identity) -> Result { let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( Id::Text("1".to_string()), "author_getNextNonce".to_owned(), diff --git a/tee-worker/bitacross/core/rpc-client/src/error.rs b/tee-worker/common/core/rpc-client/src/error.rs similarity index 100% rename from tee-worker/bitacross/core/rpc-client/src/error.rs rename to tee-worker/common/core/rpc-client/src/error.rs diff --git a/tee-worker/bitacross/core/rpc-client/src/lib.rs b/tee-worker/common/core/rpc-client/src/lib.rs similarity index 100% rename from tee-worker/bitacross/core/rpc-client/src/lib.rs rename to tee-worker/common/core/rpc-client/src/lib.rs diff --git a/tee-worker/identity/core/rpc-client/src/mock.rs b/tee-worker/common/core/rpc-client/src/mock.rs similarity index 95% rename from tee-worker/identity/core/rpc-client/src/mock.rs rename to tee-worker/common/core/rpc-client/src/mock.rs index ef1f67e6ff..173832e5ab 100644 --- a/tee-worker/identity/core/rpc-client/src/mock.rs +++ b/tee-worker/common/core/rpc-client/src/mock.rs @@ -22,7 +22,7 @@ use codec::Decode; use frame_metadata::RuntimeMetadataPrefixed; use itp_api_client_types::Metadata; use itp_stf_primitives::types::ShardIdentifier; -use itp_types::{MrEnclave, H256}; +use itp_types::MrEnclave; use litentry_primitives::Identity; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use std::{sync::mpsc::Sender as MpscSender, thread::JoinHandle}; @@ -122,8 +122,4 @@ impl DirectApi for DirectClientMock { fn get_state_mrenclave(&self) -> Result { unimplemented!() } - - fn get_id_graph_hash(&self, _shard: &ShardIdentifier, _identity: &Identity) -> Result { - unimplemented!() - } } diff --git a/tee-worker/bitacross/core/rpc-client/src/ws_client.rs b/tee-worker/common/core/rpc-client/src/ws_client.rs similarity index 100% rename from tee-worker/bitacross/core/rpc-client/src/ws_client.rs rename to tee-worker/common/core/rpc-client/src/ws_client.rs diff --git a/tee-worker/common/core/tls-websocket-server/Cargo.toml b/tee-worker/common/core/tls-websocket-server/Cargo.toml new file mode 100644 index 0000000000..09f648f951 --- /dev/null +++ b/tee-worker/common/core/tls-websocket-server/Cargo.toml @@ -0,0 +1,64 @@ +[package] +name = "itc-tls-websocket-server" +version = "0.1.0" +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = "2021" + +[dependencies] +bit-vec = { workspace = true } +chrono = { workspace = true } +log = { workspace = true } +rcgen = { workspace = true } + +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } + +mio-extras = { workspace = true, optional = true } +mio_sgx = { workspace = true, optional = true } +rustls_sgx = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } +tungstenite_sgx = { workspace = true, optional = true } +webpki_sgx = { workspace = true, optional = true } +yasna_sgx = { workspace = true, optional = true } + +mio = { workspace = true, optional = true } +rustls = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +tungstenite = { workspace = true, features = ["rustls-tls-webpki-roots"], optional = true } +webpki = { workspace = true, optional = true } +yasna = { workspace = true, features = ["bit-vec", "num-bigint", "chrono", "std"], optional = true } + +sp-core = { workspace = true, features = ["full_crypto"] } + +[dev-dependencies] +env_logger = { workspace = true } +rustls = { workspace = true, features = ["dangerous_configuration"] } +url = { version = "2.0.0" } # no workspace dep + +[features] +default = ["std"] +sgx = [ + "mio-extras/sgx", + "mio_sgx", + "rcgen/sgx", + "rcgen/pem_sgx", + "rustls_sgx", + "sgx_tstd", + "thiserror_sgx", + "tungstenite_sgx", + "webpki_sgx", + "yasna_sgx", +] +std = [ + "mio", + "mio-extras/std", + "rcgen/std", + "rcgen/pem", + "rustls", + "thiserror", + "tungstenite", + "webpki", + "yasna", + "log/std", + "sp-core/std", +] +mocks = [] diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/certificate_generation.rs b/tee-worker/common/core/tls-websocket-server/src/certificate_generation.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/certificate_generation.rs rename to tee-worker/common/core/tls-websocket-server/src/certificate_generation.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/config_provider.rs b/tee-worker/common/core/tls-websocket-server/src/config_provider.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/config_provider.rs rename to tee-worker/common/core/tls-websocket-server/src/config_provider.rs diff --git a/tee-worker/identity/core/tls-websocket-server/src/connection.rs b/tee-worker/common/core/tls-websocket-server/src/connection.rs similarity index 100% rename from tee-worker/identity/core/tls-websocket-server/src/connection.rs rename to tee-worker/common/core/tls-websocket-server/src/connection.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/connection_id_generator.rs b/tee-worker/common/core/tls-websocket-server/src/connection_id_generator.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/connection_id_generator.rs rename to tee-worker/common/core/tls-websocket-server/src/connection_id_generator.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/error.rs b/tee-worker/common/core/tls-websocket-server/src/error.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/error.rs rename to tee-worker/common/core/tls-websocket-server/src/error.rs diff --git a/tee-worker/identity/core/tls-websocket-server/src/lib.rs b/tee-worker/common/core/tls-websocket-server/src/lib.rs similarity index 100% rename from tee-worker/identity/core/tls-websocket-server/src/lib.rs rename to tee-worker/common/core/tls-websocket-server/src/lib.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/stream_state.rs b/tee-worker/common/core/tls-websocket-server/src/stream_state.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/stream_state.rs rename to tee-worker/common/core/tls-websocket-server/src/stream_state.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/mod.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/mod.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/mod.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/mod.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_cert.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_cert.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_cert.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_cert.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_private_key.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_private_key.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_private_key.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_private_key.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_server.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_server.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_server.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_server.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs b/tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs rename to tee-worker/common/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/mod.rs b/tee-worker/common/core/tls-websocket-server/src/test/mocks/mod.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/mod.rs rename to tee-worker/common/core/tls-websocket-server/src/test/mocks/mod.rs diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs b/tee-worker/common/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs similarity index 100% rename from tee-worker/identity/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs rename to tee-worker/common/core/tls-websocket-server/src/test/mocks/web_socket_connection_mock.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs b/tee-worker/common/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs rename to tee-worker/common/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/test/mod.rs b/tee-worker/common/core/tls-websocket-server/src/test/mod.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/test/mod.rs rename to tee-worker/common/core/tls-websocket-server/src/test/mod.rs diff --git a/tee-worker/bitacross/core/tls-websocket-server/src/tls_common.rs b/tee-worker/common/core/tls-websocket-server/src/tls_common.rs similarity index 100% rename from tee-worker/bitacross/core/tls-websocket-server/src/tls_common.rs rename to tee-worker/common/core/tls-websocket-server/src/tls_common.rs diff --git a/tee-worker/identity/core/tls-websocket-server/src/ws_server.rs b/tee-worker/common/core/tls-websocket-server/src/ws_server.rs similarity index 100% rename from tee-worker/identity/core/tls-websocket-server/src/ws_server.rs rename to tee-worker/common/core/tls-websocket-server/src/ws_server.rs diff --git a/tee-worker/common/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml b/tee-worker/common/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml new file mode 100644 index 0000000000..574720bda0 --- /dev/null +++ b/tee-worker/common/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "lc-parachain-extrinsic-task-receiver" +version = "0.1.0" +edition = "2021" + +[dependencies] +log = { workspace = true } + +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } + +itp-extrinsics-factory = { workspace = true } +itp-ocall-api = { workspace = true } +itp-types = { workspace = true } +lc-parachain-extrinsic-task-sender = { workspace = true } + +[features] +default = ["std"] +std = [ + "log/std", + "lc-parachain-extrinsic-task-sender/std", +] +sgx = [ + "sgx_tstd", + "lc-parachain-extrinsic-task-sender/sgx", +] diff --git a/tee-worker/identity/litentry/core/parachain-extrinsic-task/receiver/src/lib.rs b/tee-worker/common/litentry/core/parachain-extrinsic-task/receiver/src/lib.rs similarity index 100% rename from tee-worker/identity/litentry/core/parachain-extrinsic-task/receiver/src/lib.rs rename to tee-worker/common/litentry/core/parachain-extrinsic-task/receiver/src/lib.rs diff --git a/tee-worker/common/litentry/core/parachain-extrinsic-task/sender/Cargo.toml b/tee-worker/common/litentry/core/parachain-extrinsic-task/sender/Cargo.toml new file mode 100644 index 0000000000..0fc1f82878 --- /dev/null +++ b/tee-worker/common/litentry/core/parachain-extrinsic-task/sender/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "lc-parachain-extrinsic-task-sender" +version = "0.1.0" +edition = "2021" + +[dependencies] +lazy_static = { workspace = true } +log = { workspace = true } + +itp-types = { workspace = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } + +[features] +default = ["std"] +sgx = [ + "sgx_tstd", +] +std = [ + "log/std", +] diff --git a/tee-worker/identity/litentry/core/parachain-extrinsic-task/sender/src/lib.rs b/tee-worker/common/litentry/core/parachain-extrinsic-task/sender/src/lib.rs similarity index 100% rename from tee-worker/identity/litentry/core/parachain-extrinsic-task/sender/src/lib.rs rename to tee-worker/common/litentry/core/parachain-extrinsic-task/sender/src/lib.rs diff --git a/tee-worker/common/litentry/core/teebag-storage/Cargo.toml b/tee-worker/common/litentry/core/teebag-storage/Cargo.toml new file mode 100644 index 0000000000..709189d5c2 --- /dev/null +++ b/tee-worker/common/litentry/core/teebag-storage/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "lc-teebag-storage" +version = "0.1.0" +authors = ['Trust Computing GmbH '] +edition = "2021" + +[dependencies] +itp-storage = { workspace = true } +itp-types = { workspace = true } +sp-std = { workspace = true } + +[features] +default = ["std"] +std = [ + "sp-std/std", + "itp-storage/std", + "itp-types/std", +] diff --git a/tee-worker/bitacross/litentry/core/teebag-storage/src/lib.rs b/tee-worker/common/litentry/core/teebag-storage/src/lib.rs similarity index 100% rename from tee-worker/bitacross/litentry/core/teebag-storage/src/lib.rs rename to tee-worker/common/litentry/core/teebag-storage/src/lib.rs diff --git a/tee-worker/bitacross/litentry/macros/Cargo.toml b/tee-worker/common/litentry/macros/Cargo.toml similarity index 84% rename from tee-worker/bitacross/litentry/macros/Cargo.toml rename to tee-worker/common/litentry/macros/Cargo.toml index f8c3e9f862..af0f970af8 100644 --- a/tee-worker/bitacross/litentry/macros/Cargo.toml +++ b/tee-worker/common/litentry/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Trust Computing GmbH "] -name = "litentry-macros" +name = "litentry-worker-macros" version = "0.1.0" edition = "2021" diff --git a/tee-worker/bitacross/litentry/macros/src/lib.rs b/tee-worker/common/litentry/macros/src/lib.rs similarity index 100% rename from tee-worker/bitacross/litentry/macros/src/lib.rs rename to tee-worker/common/litentry/macros/src/lib.rs diff --git a/tee-worker/common/litentry/pallets/identity-management/Cargo.toml b/tee-worker/common/litentry/pallets/identity-management/Cargo.toml new file mode 100644 index 0000000000..0a6b5d8c5e --- /dev/null +++ b/tee-worker/common/litentry/pallets/identity-management/Cargo.toml @@ -0,0 +1,42 @@ +[package] +authors = ['Trust Computing GmbH ', 'Integritee AG '] +edition = '2021' +homepage = 'https://litentry.com' +name = 'pallet-identity-management-tee' +repository = 'https://github.com/litentry/litentry-parachain' +version = '0.1.0' + +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["max-encoded-len"] } +hex = { workspace = true } +log = { workspace = true } +scale-info = { workspace = true } + +frame-support = { workspace = true } +frame-system = { workspace = true } +litentry-primitives = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +[dev-dependencies] +pallet-balances = { workspace = true } + +[features] +default = ["std"] + +std = [ + "codec/std", + "sp-std/std", + "sp-runtime/std", + "sp-io/std", + "sp-core/std", + "frame-support/std", + "frame-system/std", + "log/std", + "pallet-balances/std", + "litentry-primitives/std", +] + +development = [] diff --git a/tee-worker/identity/litentry/pallets/identity-management/src/identity_context.rs b/tee-worker/common/litentry/pallets/identity-management/src/identity_context.rs similarity index 100% rename from tee-worker/identity/litentry/pallets/identity-management/src/identity_context.rs rename to tee-worker/common/litentry/pallets/identity-management/src/identity_context.rs diff --git a/tee-worker/identity/litentry/pallets/identity-management/src/lib.rs b/tee-worker/common/litentry/pallets/identity-management/src/lib.rs similarity index 100% rename from tee-worker/identity/litentry/pallets/identity-management/src/lib.rs rename to tee-worker/common/litentry/pallets/identity-management/src/lib.rs diff --git a/tee-worker/identity/litentry/pallets/identity-management/src/migrations.rs b/tee-worker/common/litentry/pallets/identity-management/src/migrations.rs similarity index 100% rename from tee-worker/identity/litentry/pallets/identity-management/src/migrations.rs rename to tee-worker/common/litentry/pallets/identity-management/src/migrations.rs diff --git a/tee-worker/identity/litentry/pallets/identity-management/src/mock.rs b/tee-worker/common/litentry/pallets/identity-management/src/mock.rs similarity index 100% rename from tee-worker/identity/litentry/pallets/identity-management/src/mock.rs rename to tee-worker/common/litentry/pallets/identity-management/src/mock.rs diff --git a/tee-worker/identity/litentry/pallets/identity-management/src/tests.rs b/tee-worker/common/litentry/pallets/identity-management/src/tests.rs similarity index 100% rename from tee-worker/identity/litentry/pallets/identity-management/src/tests.rs rename to tee-worker/common/litentry/pallets/identity-management/src/tests.rs diff --git a/tee-worker/common/litentry/primitives/Cargo.toml b/tee-worker/common/litentry/primitives/Cargo.toml new file mode 100644 index 0000000000..9a1c2bd38b --- /dev/null +++ b/tee-worker/common/litentry/primitives/Cargo.toml @@ -0,0 +1,62 @@ +[package] +authors = ["Trust Computing GmbH "] +edition = "2021" +name = "litentry-primitives" +version = "0.1.0" + +[dependencies] +bitcoin = { workspace = true, features = ["secp-recovery", "no-std"] } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +log = { workspace = true } +rand = { workspace = true, optional = true } +rand-sgx = { workspace = true, optional = true } +ring = { workspace = true } +scale-info = { workspace = true } +secp256k1 = { workspace = true } +serde = { workspace = true } + +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } + +itp-sgx-crypto = { workspace = true } +itp-sgx-runtime-primitives = { workspace = true } +pallet-teebag = { workspace = true } +parentchain-primitives = { workspace = true } + +[dev-dependencies] +base64 = { workspace = true } + +[features] +default = ["std"] +development = [ + "parentchain-primitives/development", +] +sgx = [ + "sgx_tstd", + "rand-sgx", + "itp-sgx-crypto/sgx", +] +std = [ + "hex/std", + "codec/std", + "serde/std", + "scale-info/std", + "itp-sgx-crypto/std", + "itp-sgx-runtime-primitives/std", + "sp-core/std", + "sp-std/std", + "sp-io/std", + "sp-runtime/std", + "ring/std", + "parentchain-primitives/std", + "pallet-teebag/std", + "rand", + "log/std", + "bitcoin/std", + "secp256k1/std", +] diff --git a/tee-worker/bitacross/litentry/primitives/src/aes.rs b/tee-worker/common/litentry/primitives/src/aes.rs similarity index 100% rename from tee-worker/bitacross/litentry/primitives/src/aes.rs rename to tee-worker/common/litentry/primitives/src/aes.rs diff --git a/tee-worker/identity/litentry/primitives/src/aes_request.rs b/tee-worker/common/litentry/primitives/src/aes_request.rs similarity index 100% rename from tee-worker/identity/litentry/primitives/src/aes_request.rs rename to tee-worker/common/litentry/primitives/src/aes_request.rs diff --git a/tee-worker/identity/litentry/primitives/src/bitcoin_address.rs b/tee-worker/common/litentry/primitives/src/bitcoin_address.rs similarity index 100% rename from tee-worker/identity/litentry/primitives/src/bitcoin_address.rs rename to tee-worker/common/litentry/primitives/src/bitcoin_address.rs diff --git a/tee-worker/bitacross/litentry/primitives/src/bitcoin_signature.rs b/tee-worker/common/litentry/primitives/src/bitcoin_signature.rs similarity index 100% rename from tee-worker/bitacross/litentry/primitives/src/bitcoin_signature.rs rename to tee-worker/common/litentry/primitives/src/bitcoin_signature.rs diff --git a/tee-worker/bitacross/litentry/primitives/src/ethereum_signature.rs b/tee-worker/common/litentry/primitives/src/ethereum_signature.rs similarity index 100% rename from tee-worker/bitacross/litentry/primitives/src/ethereum_signature.rs rename to tee-worker/common/litentry/primitives/src/ethereum_signature.rs diff --git a/tee-worker/identity/litentry/primitives/src/lib.rs b/tee-worker/common/litentry/primitives/src/lib.rs similarity index 99% rename from tee-worker/identity/litentry/primitives/src/lib.rs rename to tee-worker/common/litentry/primitives/src/lib.rs index da8d5e8e94..2a14a12b82 100644 --- a/tee-worker/identity/litentry/primitives/src/lib.rs +++ b/tee-worker/common/litentry/primitives/src/lib.rs @@ -28,6 +28,8 @@ mod aes_request; mod bitcoin_address; mod bitcoin_signature; mod ethereum_signature; +mod plain_request; +mod stf_request; mod validation_data; pub use aes::*; @@ -35,7 +37,8 @@ pub use aes_request::*; pub use bitcoin_address::*; pub use bitcoin_signature::*; pub use ethereum_signature::*; -use sp_std::{boxed::Box, fmt::Debug, vec::Vec}; +pub use plain_request::*; +pub use stf_request::*; pub use validation_data::*; use bitcoin::sign_message::{signed_msg_hash, MessageSignature}; @@ -85,6 +88,7 @@ use sp_io::{ hashing::{blake2_256, keccak_256}, }; use sp_runtime::traits::Verify; +use sp_std::{boxed::Box, fmt::Debug, vec::Vec}; use std::string::{String, ToString}; #[cfg(feature = "std")] diff --git a/tee-worker/bitacross/litentry/primitives/src/plain_request.rs b/tee-worker/common/litentry/primitives/src/plain_request.rs similarity index 100% rename from tee-worker/bitacross/litentry/primitives/src/plain_request.rs rename to tee-worker/common/litentry/primitives/src/plain_request.rs diff --git a/tee-worker/identity/litentry/core/stf-task/sender/src/request.rs b/tee-worker/common/litentry/primitives/src/stf_request.rs similarity index 96% rename from tee-worker/identity/litentry/core/stf-task/sender/src/request.rs rename to tee-worker/common/litentry/primitives/src/stf_request.rs index 2983c0d979..0318214b6b 100644 --- a/tee-worker/identity/litentry/core/stf-task/sender/src/request.rs +++ b/tee-worker/common/litentry/primitives/src/stf_request.rs @@ -15,12 +15,13 @@ // along with Litentry. If not, see . // TODO: the sidechain block number type is chaotic from upstream -use codec::{Decode, Encode}; -use itp_types::{AccountId, BlockNumber as SidechainBlockNumber, H256}; -use litentry_primitives::{ +use crate::{ Assertion, Identity, IdentityNetworkTuple, ParentchainBlockNumber, RequestAesKey, ShardIdentifier, Web2ValidationData, Web3Network, }; +use codec::{Decode, Encode}; +use itp_sgx_runtime_primitives::types::{AccountId, BlockNumber as SidechainBlockNumber}; +use sp_core::H256; use sp_runtime::traits::ConstU32; use sp_std::prelude::Vec; diff --git a/tee-worker/identity/litentry/primitives/src/validation_data.rs b/tee-worker/common/litentry/primitives/src/validation_data.rs similarity index 100% rename from tee-worker/identity/litentry/primitives/src/validation_data.rs rename to tee-worker/common/litentry/primitives/src/validation_data.rs diff --git a/tee-worker/identity/.taplo.toml b/tee-worker/identity/.taplo.toml deleted file mode 100644 index a1de67fb52..0000000000 --- a/tee-worker/identity/.taplo.toml +++ /dev/null @@ -1,21 +0,0 @@ -include = ["**/Cargo.toml"] - -[formatting] -array_auto_expand = false -array_auto_collapse = false -indent_string = " " -inline_table_expand = false - -[[rule]] -include = ["**/Cargo.toml"] -keys = ["dependencies", "target", "patch"] - -[rule.formatting] -reorder_keys = true - -[[rule]] -include = ["**/Cargo.toml"] -keys = ["features"] - -[rule.formatting] -array_auto_expand = true \ No newline at end of file diff --git a/tee-worker/identity/Cargo.toml b/tee-worker/identity/Cargo.toml deleted file mode 100644 index 293cd5e653..0000000000 --- a/tee-worker/identity/Cargo.toml +++ /dev/null @@ -1,102 +0,0 @@ -[workspace] -resolver = "2" -members = [ - "app-libs/parentchain-interface", - "app-libs/sgx-runtime", - "app-libs/stf", - "cli", - "core/direct-rpc-client", - "core/direct-rpc-server", - "core/peer-top-broadcaster", - "core/offchain-worker-executor", - "core/parentchain/block-import-dispatcher", - "core/parentchain/block-importer", - "core/parentchain/indirect-calls-executor", - "core/parentchain/light-client", - "core/parentchain/parentchain-crate", - "core/rest-client", - "core/rpc-client", - "core/rpc-server", - "core/tls-websocket-server", - "core-primitives/attestation-handler", - "core-primitives/binary-merkle-tree", - "core-primitives/import-queue", - "core-primitives/component-container", - "core-primitives/enclave-api", - "core-primitives/enclave-api/ffi", - "core-primitives/enclave-metrics", - "core-primitives/extrinsics-factory", - "core-primitives/hashing", - "core-primitives/networking-utils", - "core-primitives/node-api", - "core-primitives/node-api/api-client-extensions", - "core-primitives/node-api/api-client-types", - "core-primitives/node-api/factory", - "core-primitives/node-api/metadata", - "core-primitives/node-api/metadata-provider", - "core-primitives/nonce-cache", - "core-primitives/ocall-api", - "core-primitives/primitives-cache", - "core-primitives/rpc", - "core-primitives/settings", - "core-primitives/sgx/crypto", - "core-primitives/sgx/io", - "core-primitives/sgx-runtime-primitives", - "core-primitives/stf-executor", - "core-primitives/stf-interface", - "core-primitives/stf-primitives", - "core-primitives/stf-state-handler", - "core-primitives/stf-state-observer", - "core-primitives/storage", - "core-primitives/substrate-sgx/environmental", - "core-primitives/substrate-sgx/externalities", - "core-primitives/substrate-sgx/sp-io", - "core-primitives/test", - "core-primitives/time-utils", - "core-primitives/top-pool", - "core-primitives/top-pool-author", - "core-primitives/types", - "core-primitives/utils", - "service", - "sidechain/block-composer", - "sidechain/block-verification", - "sidechain/consensus/aura", - "sidechain/consensus/common", - "sidechain/consensus/slots", - "sidechain/fork-tree", - "sidechain/peer-fetch", - "sidechain/primitives", - "sidechain/rpc-handler", - "sidechain/sidechain-crate", - "sidechain/state", - "sidechain/validateer-fetch", - "litentry/primitives", - "litentry/pallets/identity-management", - "litentry/core/stf-task/sender", - "litentry/core/stf-task/receiver", - "litentry/core/identity-verification", - "litentry/core/assertion-build", - "litentry/core/data-providers", - "litentry/core/mock-server", - "litentry/core/vc-task/sender", - "litentry/core/vc-task/receiver", - "litentry/core/dynamic-assertion", - "litentry/core/evm-dynamic-assertions", - "litentry/core/parachain-extrinsic-task/sender", - "litentry/core/parachain-extrinsic-task/receiver", -] - -[patch."https://github.com/apache/teaclave-sgx-sdk.git"] -sgx_alloc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_crypto_helper = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_libc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_rand = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_tcrypto = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_trts = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_tstd = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_types = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_ucrypto = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -sgx_urts = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } - -[patch.crates-io] -ring = { git = "https://github.com/betrusted-io/ring-xous", branch = "0.16.20-cleanup" } diff --git a/tee-worker/identity/Makefile b/tee-worker/identity/Makefile index 7502ad23ae..b3ebf1e1d5 100755 --- a/tee-worker/identity/Makefile +++ b/tee-worker/identity/Makefile @@ -119,14 +119,14 @@ Worker_Rust_Flags := $(CARGO_TARGET) $(WORKER_FEATURES) Worker_Include_Paths := -I ./service -I./include -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) Worker_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(Worker_Include_Paths) -Worker_Rust_Path := target/$(OUTPUT_PATH) +Worker_Rust_Path := ../target/$(OUTPUT_PATH) Worker_Enclave_u_Object :=service/libEnclave_u.a Worker_Name := bin/app ######## litentry-cli settings ######## Client_Rust_Flags := $(CARGO_TARGET) $(CLIENT_FEATURES) -Client_Rust_Path := target/$(OUTPUT_PATH) +Client_Rust_Path := ../target/$(OUTPUT_PATH) Client_Path := bin Client_Binary := litentry-cli Client_Name := $(Client_Path)/$(Client_Binary) diff --git a/tee-worker/identity/app-libs/parentchain-interface/Cargo.toml b/tee-worker/identity/app-libs/parentchain-interface/Cargo.toml index 46cd6d9f6d..3718f96eb0 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/Cargo.toml +++ b/tee-worker/identity/app-libs/parentchain-interface/Cargo.toml @@ -1,49 +1,42 @@ [package] -name = "ita-parentchain-interface" +name = "id-ita-parentchain-interface" version = "0.1.0" authors = ["Integritee AG "] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, optional = true } -# local dependencies -ita-sgx-runtime = { path = "../sgx-runtime", default-features = false } -ita-stf = { path = "../stf", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../../core/parentchain/indirect-calls-executor", default-features = false } -itp-api-client-types = { path = "../../core-primitives/node-api/api-client-types", default-features = false } -itp-enclave-metrics = { path = "../../core-primitives/enclave-metrics", default-features = false } -itp-node-api = { path = "../../core-primitives/node-api", default-features = false } -itp-ocall-api = { path = "../../core-primitives/ocall-api", default-features = false } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../sgx-runtime", default-features = false } +ita-stf = { package = "id-ita-stf", path = "../stf", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "id-itc-parentchain-indirect-calls-executor", path = "../../core/parentchain/indirect-calls-executor", default-features = false } +itp-api-client-types = { workspace = true } +itp-enclave-metrics = { workspace = true } +itp-node-api = { workspace = true } +itp-ocall-api = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } -# no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } -substrate-api-client = { optional = true, default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +substrate-api-client = { workspace = true, optional = true } -# substrate dep -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -lc-dynamic-assertion = { path = "../../litentry/core/dynamic-assertion", default-features = false } -lc-evm-dynamic-assertions = { path = "../../litentry/core/evm-dynamic-assertions", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +lc-dynamic-assertion = { workspace = true } +lc-evm-dynamic-assertions = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -env_logger = "0.9.0" -itp-node-api = { path = "../../core-primitives/node-api", features = ["mocks"] } -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-executor = { path = "../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../core-primitives/test" } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", features = ["mocks"] } -itc-parentchain-test = { path = "../../core/parentchain/test" } +env_logger = { workspace = true } +itp-node-api = { workspace = true, features = ["std", "mocks"] } +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } +itp-test = { workspace = true } +itc-parentchain-test = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../core-primitives/stf-executor", features = ["mocks"] } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../core-primitives/top-pool-author", features = ["mocks"] } [features] diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_filter.rs b/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_filter.rs index 456cebe639..c27e871c70 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_filter.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_filter.rs @@ -21,14 +21,7 @@ use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{ - events::{ - ActivateIdentityRequested, AssertionCreated, DeactivateIdentityRequested, - EnclaveUnauthorized, LinkIdentityRequested, OpaqueTaskPosted, - ParentchainBlockProcessed, VCRequested, - }, - FilterEvents, - }, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -104,4 +97,24 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { self.filter() } + + fn get_relayer_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_relayers_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_btc_wallet_generated_events(&self) -> Result, Self::Error> { + self.filter() + } } diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_handler.rs b/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_handler.rs index 015cdaee70..a46eba6cc0 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_handler.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/integritee/event_handler.rs @@ -50,7 +50,7 @@ impl ParentchainEventHandler where MetricsApi: EnclaveMetricsOCallApi, { - fn link_identity>( + fn link_identity>( executor: &Executor, account: &AccountId, encrypted_identity: Vec, @@ -86,7 +86,7 @@ where Ok(()) } - fn deactivate_identity>( + fn deactivate_identity>( executor: &Executor, account: &AccountId, encrypted_identity: Vec, @@ -114,7 +114,7 @@ where Ok(()) } - fn activate_identity>( + fn activate_identity>( executor: &Executor, account: &AccountId, encrypted_identity: Vec, @@ -142,7 +142,7 @@ where Ok(()) } - fn request_vc>( + fn request_vc>( executor: &Executor, account: &AccountId, assertion: Assertion, @@ -168,7 +168,7 @@ where Ok(()) } - fn post_opaque_task>( + fn post_opaque_task>( executor: &Executor, request: &RsaRequest, ) -> Result<(), Error> { @@ -178,7 +178,7 @@ where Ok(()) } - fn store_assertion>( + fn store_assertion>( &self, executor: &Executor, id: H160, @@ -221,12 +221,13 @@ where } } -impl HandleParentchainEvents +impl HandleParentchainEvents for ParentchainEventHandler where - Executor: IndirectExecutor, + Executor: IndirectExecutor, MetricsApi: EnclaveMetricsOCallApi, { + type Output = ProcessedEventsArtifacts; fn handle_events( &self, executor: &Executor, diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_filter.rs b/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_filter.rs index 2490b2e1d9..c3b102a895 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_filter.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_filter.rs @@ -20,7 +20,7 @@ use itc_parentchain_indirect_calls_executor::event_filter::ToEvents; use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{events::AssertionCreated, FilterEvents}, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -105,4 +105,24 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { Ok(Vec::new()) } + + fn get_relayer_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_relayers_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_btc_wallet_generated_events(&self) -> Result, Self::Error> { + self.filter() + } } diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_handler.rs b/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_handler.rs index af091e98f8..47d1db3382 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_handler.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/target_a/event_handler.rs @@ -26,11 +26,12 @@ use sp_std::vec::Vec; pub struct ParentchainEventHandler {} -impl HandleParentchainEvents +impl HandleParentchainEvents for ParentchainEventHandler where - Executor: IndirectExecutor, + Executor: IndirectExecutor, { + type Output = ProcessedEventsArtifacts; fn handle_events( &self, _executor: &Executor, diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_filter.rs b/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_filter.rs index 2490b2e1d9..c3b102a895 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_filter.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_filter.rs @@ -20,7 +20,7 @@ use itc_parentchain_indirect_calls_executor::event_filter::ToEvents; use itp_api_client_types::Events; use itp_node_api::api_client::StaticEvent; use itp_types::{ - parentchain::{events::AssertionCreated, FilterEvents}, + parentchain::{events::*, FilterEvents}, H256, }; use std::vec::Vec; @@ -105,4 +105,24 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { Ok(Vec::new()) } + + fn get_relayer_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_relayers_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_added_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_enclave_removed_events(&self) -> Result, Self::Error> { + self.filter() + } + + fn get_btc_wallet_generated_events(&self) -> Result, Self::Error> { + self.filter() + } } diff --git a/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_handler.rs b/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_handler.rs index 56151a9ccc..5e79be6a99 100644 --- a/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_handler.rs +++ b/tee-worker/identity/app-libs/parentchain-interface/src/target_b/event_handler.rs @@ -26,11 +26,12 @@ use sp_std::vec::Vec; pub struct ParentchainEventHandler {} -impl HandleParentchainEvents +impl HandleParentchainEvents for ParentchainEventHandler where - Executor: IndirectExecutor, + Executor: IndirectExecutor, { + type Output = ProcessedEventsArtifacts; fn handle_events( &self, _executor: &Executor, diff --git a/tee-worker/identity/app-libs/sgx-runtime/Cargo.toml b/tee-worker/identity/app-libs/sgx-runtime/Cargo.toml index da74d62206..4ab2da5325 100644 --- a/tee-worker/identity/app-libs/sgx-runtime/Cargo.toml +++ b/tee-worker/identity/app-libs/sgx-runtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ita-sgx-runtime" +name = "id-ita-sgx-runtime" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" @@ -8,39 +8,34 @@ edition = "2021" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", workspace = true } +scale-info = { workspace = true } -# local dependencies -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } +itp-sgx-runtime-primitives = { workspace = true } -# Substrate dependencies -frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +pallet-balances = { workspace = true } +pallet-sudo = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-transaction-payment = { workspace = true } +sp-api = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +sp-version = { workspace = true } -# Integritee dependencies -pallet-evm = { default-features = false, optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "bar/polkadot-v0.9.42" } - -# Litentry -pallet-imt = { package = "pallet-identity-management-tee", path = "../../litentry/pallets/identity-management", default-features = false } +# TODO - move to tee-worker pallets +pallet-evm = { git = "https://github.com/integritee-network/frontier", branch = "bar/polkadot-v0.9.42", default-features = false, optional = true } +pallet-identity-management-tee = { workspace = true } pallet-parentchain = { package = "pallet-parentchain", path = "../../../../parachain/worker-pallets/parentchain", default-features = false } [features] default = ["std"] -# Compile the sgx-runtime with evm support. evm = ["pallet-evm"] development = [ - "pallet-imt/development", + "pallet-identity-management-tee/development", ] std = [ "codec/std", @@ -60,6 +55,5 @@ std = [ "sp-runtime/std", "sp-std/std", "sp-version/std", - # litentry - "pallet-imt/std", + "pallet-identity-management-tee/std", ] diff --git a/tee-worker/identity/app-libs/sgx-runtime/src/lib.rs b/tee-worker/identity/app-libs/sgx-runtime/src/lib.rs index c13954a4cf..a388b2d910 100644 --- a/tee-worker/identity/app-libs/sgx-runtime/src/lib.rs +++ b/tee-worker/identity/app-libs/sgx-runtime/src/lib.rs @@ -82,7 +82,9 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; // litentry -pub use pallet_imt::{self, Call as IdentityManagementCall, IDGraph, IdentityStatus}; +pub use pallet_identity_management_tee::{ + self, Call as IdentityManagementCall, IDGraph, IdentityStatus, +}; /// Block type as expected by this sgx-runtime. pub type Block = generic::Block; @@ -283,7 +285,7 @@ impl pallet_parentchain::Config for Runtime { type WeightInfo = (); } -impl pallet_imt::Config for Runtime { +impl pallet_identity_management_tee::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ManageOrigin = EnsureRoot; type MaxIDGraphLength = ConstU32<64>; @@ -305,7 +307,7 @@ construct_runtime!( ParentchainLitentry: pallet_parentchain::, ParentchainTargetA: pallet_parentchain::, ParentchainTargetB: pallet_parentchain::, - IdentityManagement: pallet_imt, + IdentityManagement: pallet_identity_management_tee, } ); @@ -328,7 +330,7 @@ construct_runtime!( ParentchainLitentry: pallet_parentchain::, ParentchainTargetA: pallet_parentchain::, ParentchainTargetB: pallet_parentchain::, - IdentityManagement: pallet_imt, + IdentityManagement: pallet_identity_management_tee, Evm: pallet_evm, } ); diff --git a/tee-worker/identity/app-libs/sgx-runtime/src/migration.rs b/tee-worker/identity/app-libs/sgx-runtime/src/migration.rs index 9afe261b80..3ddd26649e 100644 --- a/tee-worker/identity/app-libs/sgx-runtime/src/migration.rs +++ b/tee-worker/identity/app-libs/sgx-runtime/src/migration.rs @@ -9,6 +9,6 @@ use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; pub struct Upgrade; impl OnRuntimeUpgrade for Upgrade { fn on_runtime_upgrade() -> Weight { - pallet_imt::migrations::migrate_to_v1::() + pallet_identity_management_tee::migrations::migrate_to_v1::() } } diff --git a/tee-worker/identity/app-libs/stf/Cargo.toml b/tee-worker/identity/app-libs/stf/Cargo.toml index f72735e0ff..20f5d40d85 100644 --- a/tee-worker/identity/app-libs/stf/Cargo.toml +++ b/tee-worker/identity/app-libs/stf/Cargo.toml @@ -1,53 +1,50 @@ [package] -name = "ita-stf" +name = "id-ita-stf" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# crates.io -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -hex = { version = "0.4", default-features = false } -hex-literal = { version = "0.4" } -log = { version = "0.4", default-features = false } -rlp = { version = "0.5", default-features = false } -sha3 = { version = "0.10", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +hex-literal = { workspace = true } +log = { workspace = true } +rlp = { workspace = true } +sha3 = { workspace = true } -# sgx deps -sgx_tstd = { branch = "master", features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, features = ["untrusted_fs", "net", "backtrace"], optional = true } -# local crates -ita-sgx-runtime = { default-features = false, path = "../sgx-runtime" } -itp-hashing = { default-features = false, path = "../../core-primitives/hashing" } -itp-node-api = { default-features = false, path = "../../core-primitives/node-api" } -itp-node-api-metadata = { default-features = false, path = "../../core-primitives/node-api/metadata" } -itp-sgx-externalities = { default-features = false, path = "../../core-primitives/substrate-sgx/externalities" } -itp-stf-interface = { default-features = false, path = "../../core-primitives/stf-interface" } -itp-stf-primitives = { default-features = false, path = "../../core-primitives/stf-primitives" } -itp-storage = { default-features = false, path = "../../core-primitives/storage" } -itp-types = { default-features = false, path = "../../core-primitives/types" } -itp-utils = { default-features = false, path = "../../core-primitives/utils" } -sp-io = { default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"], path = "../../core-primitives/substrate-sgx/sp-io" } +itp-hashing = { workspace = true } +itp-node-api = { workspace = true } +itp-node-api-metadata = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } -# Substrate dependencies -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../sgx-runtime", default-features = false } +sp-io = { path = "../../../common/core-primitives/substrate-sgx/sp-io", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"] } + +frame-support = { workspace = true } +frame-system = { workspace = true } +pallet-balances = { workspace = true } +pallet-sudo = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } +sp-std = { workspace = true } # litentry -itp-node-api-metadata-provider = { path = "../../core-primitives/node-api/metadata-provider", default-features = false } +itp-node-api-metadata-provider = { workspace = true } lc-stf-task-sender = { path = "../../litentry/core/stf-task/sender", default-features = false } -litentry-hex-utils = { path = "../../../../common/utils/hex", default-features = false } +litentry-hex-utils = { workspace = true } litentry-macros = { path = "../../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +litentry-primitives = { workspace = true } pallet-parentchain = { path = "../../../../parachain/worker-pallets/parentchain", default-features = false } [dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-keyring = { workspace = true } [features] default = ["std"] @@ -57,16 +54,13 @@ sgx = [ "itp-sgx-externalities/sgx", "sp-io/sgx", "itp-node-api/sgx", - # litentry "litentry-primitives/sgx", "lc-stf-task-sender/sgx", "itp-node-api-metadata-provider/sgx", ] std = [ - # crates.io "codec/std", "log/std", - # local "ita-sgx-runtime/std", "itp-hashing/std", "itp-sgx-externalities/std", @@ -75,17 +69,14 @@ std = [ "itp-types/std", "itp-node-api/std", "itp-node-api-metadata/std", - # substrate "sp-core/std", "pallet-balances/std", "pallet-sudo/std", "frame-system/std", "frame-support/std", "sp-runtime/std", - # scs/integritee "pallet-parentchain/std", "sp-io/std", - # litentry "litentry-primitives/std", "lc-stf-task-sender/std", "itp-node-api-metadata-provider/std", diff --git a/tee-worker/identity/app-libs/stf/src/trusted_call.rs b/tee-worker/identity/app-libs/stf/src/trusted_call.rs index 7f146bcc76..0fc8c6f11c 100644 --- a/tee-worker/identity/app-libs/stf/src/trusted_call.rs +++ b/tee-worker/identity/app-libs/stf/src/trusted_call.rs @@ -65,7 +65,7 @@ use sp_io::hashing::blake2_256; use sp_runtime::{traits::ConstU32, BoundedVec, MultiAddress}; pub type IMTCall = ita_sgx_runtime::IdentityManagementCall; -pub type IMT = ita_sgx_runtime::pallet_imt::Pallet; +pub type IMT = ita_sgx_runtime::pallet_identity_management_tee::Pallet; pub type MaxAssertionLength = ConstU32<128>; pub type VecAssertion = BoundedVec; diff --git a/tee-worker/identity/app-libs/stf/src/trusted_call_litentry.rs b/tee-worker/identity/app-libs/stf/src/trusted_call_litentry.rs index dd15f6069c..ea4bf0ed1b 100644 --- a/tee-worker/identity/app-libs/stf/src/trusted_call_litentry.rs +++ b/tee-worker/identity/app-libs/stf/src/trusted_call_litentry.rs @@ -35,11 +35,12 @@ use itp_stf_primitives::{ }; use itp_types::{parentchain::ParentchainCall, OpaqueCall, H256}; use itp_utils::stringify::account_id_to_string; -use lc_stf_task_sender::{ - RequestType, SendStfRequest, StfRequestSender, Web2IdentityVerificationRequest, -}; +use lc_stf_task_sender::{SendStfRequest, StfRequestSender}; use litentry_macros::if_development_or; -use litentry_primitives::{ErrorDetail, Identity, RequestAesKey, ValidationData, Web3Network}; +use litentry_primitives::{ + ErrorDetail, Identity, RequestAesKey, RequestType, ValidationData, + Web2IdentityVerificationRequest, Web3Network, +}; use log::*; impl TrustedCallSigned { diff --git a/tee-worker/identity/cli/Cargo.toml b/tee-worker/identity/cli/Cargo.toml index ed78efc647..b0f273b20d 100644 --- a/tee-worker/identity/cli/Cargo.toml +++ b/tee-worker/identity/cli/Cargo.toml @@ -6,53 +6,49 @@ edition = "2021" [dependencies] array-bytes = { version = "6.0.0" } -base58 = "0.2" +base58 = { workspace = true } chrono = "*" clap = { version = "=4.1.0", features = ["derive"] } -codec = { version = "3.0.0", package = "parity-scale-codec", features = ["derive"] } -env_logger = "0.9" +codec = { package = "parity-scale-codec", workspace = true, features = ["std"] } +env_logger = { workspace = true } hdrhistogram = "7.5.0" -hex = "0.4.2" -log = "0.4" +hex = { workspace = true, features = ["std"] } +log = { workspace = true, features = ["std"] } rand = "0.8.5" rayon = "1.5.1" regex = "1.9.5" reqwest = { version = "0.11", features = ["blocking", "json"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -thiserror = "1.0" +serde = { workspace = true, features = ["std"] } +serde_json = { workspace = true, features = ["std"] } +thiserror = { workspace = true } urlencoding = "2.1.3" -# scs / integritee -ita-parentchain-interface = { path = "../app-libs/parentchain-interface" } -pallet-evm = { optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "bar/polkadot-v0.9.42" } +pallet-evm = { git = "https://github.com/integritee-network/frontier", branch = "bar/polkadot-v0.9.42", optional = true } +sgx_crypto_helper = { workspace = true } -substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } -substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } +substrate-api-client = { workspace = true } +substrate-client-keystore = { workspace = true } -# substrate dependencies -sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-application-crypto = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } +sp-keyring = { workspace = true } +sp-keystore = { workspace = true, features = ["std"] } +sp-runtime = { workspace = true, features = ["std"] } -# local dependencies -ita-stf = { path = "../app-libs/stf" } -itc-rpc-client = { path = "../core/rpc-client" } -itp-node-api = { path = "../core-primitives/node-api" } -itp-rpc = { path = "../core-primitives/rpc" } -itp-sgx-crypto = { path = "../core-primitives/sgx/crypto" } -itp-stf-primitives = { path = "../core-primitives/stf-primitives" } -itp-types = { path = "../core-primitives/types" } -itp-utils = { path = "../core-primitives/utils" } +ita-parentchain-interface = { package = "id-ita-parentchain-interface", path = "../app-libs/parentchain-interface" } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../app-libs/sgx-runtime" } +ita-stf = { package = "id-ita-stf", path = "../app-libs/stf" } +itc-rpc-client = { workspace = true } +itp-node-api = { workspace = true, features = ["std"] } +itp-rpc = { workspace = true, features = ["std"] } +itp-sgx-crypto = { workspace = true, features = ["std"] } +itp-stf-primitives = { workspace = true, features = ["std"] } +itp-types = { workspace = true, features = ["std"] } +itp-utils = { workspace = true, features = ["std"] } -# litentry frame-metadata = "15.0.0" -ita-sgx-runtime = { path = "../app-libs/sgx-runtime" } -litentry-hex-utils = { path = "../../../common/utils/hex", default-features = false } -litentry-primitives = { path = "../litentry/primitives" } +litentry-hex-utils = { workspace = true } +litentry-primitives = { workspace = true, features = ["std"] } scale-value = "0.6.0" sp-core-hashing = "6.0.0" diff --git a/tee-worker/identity/cli/src/base_cli/commands/litentry/id_graph_hash.rs b/tee-worker/identity/cli/src/base_cli/commands/litentry/id_graph_hash.rs index 237238dd8f..44cdb06905 100644 --- a/tee-worker/identity/cli/src/base_cli/commands/litentry/id_graph_hash.rs +++ b/tee-worker/identity/cli/src/base_cli/commands/litentry/id_graph_hash.rs @@ -14,7 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Litentry. If not, see . -use crate::{command_utils::get_worker_api_direct, Cli, CliResult, CliResultOk}; +use crate::{ + command_utils::get_worker_api_direct, trusted_operation::get_id_graph_hash, Cli, CliResult, + CliResultOk, H256, +}; use codec::Decode; use itc_rpc_client::direct_client::DirectApi; use itp_types::ShardIdentifier; @@ -36,7 +39,7 @@ impl IDGraphHashCommand { let mrenclave = direct_api.get_state_mrenclave().unwrap(); let shard = ShardIdentifier::decode(&mut &mrenclave[..]).unwrap(); let identity = Identity::from_did(self.did.as_str()).unwrap(); - let id_graph_hash = direct_api.get_id_graph_hash(&shard, &identity).unwrap(); + let id_graph_hash = get_id_graph_hash::(&direct_api, &shard, &identity).unwrap(); println!("{:?}", id_graph_hash); Ok(CliResultOk::None) diff --git a/tee-worker/identity/cli/src/benchmark/request_vc.rs b/tee-worker/identity/cli/src/benchmark/request_vc.rs index 4730f29c95..2792e94172 100644 --- a/tee-worker/identity/cli/src/benchmark/request_vc.rs +++ b/tee-worker/identity/cli/src/benchmark/request_vc.rs @@ -8,7 +8,7 @@ use crate::{ }; use clap::Parser; use core::time::Duration; -use ita_sgx_runtime::pallet_imt::Identity; +use ita_sgx_runtime::pallet_identity_management_tee::Identity; use ita_stf::{Getter, TrustedCall, TrustedCallSigned}; use itc_rpc_client::direct_client::DirectClient; use itp_stf_primitives::{ diff --git a/tee-worker/identity/cli/src/benchmark/stf.rs b/tee-worker/identity/cli/src/benchmark/stf.rs index c7abc8bd2f..26dcb0911c 100644 --- a/tee-worker/identity/cli/src/benchmark/stf.rs +++ b/tee-worker/identity/cli/src/benchmark/stf.rs @@ -267,7 +267,7 @@ fn get_balance( ); let getter_start_timer = Instant::now(); - let getter_result = direct_client.get_state(shard, &getter); + let getter_result = get_state(direct_client, shard, &getter).ok().unwrap_or_default(); let getter_execution_time = getter_start_timer.elapsed().as_millis(); let balance = decode_balance(getter_result); diff --git a/tee-worker/identity/cli/src/trusted_base_cli/commands/litentry/get_storage.rs b/tee-worker/identity/cli/src/trusted_base_cli/commands/litentry/get_storage.rs index ae5fb5860d..66ce2e6a57 100644 --- a/tee-worker/identity/cli/src/trusted_base_cli/commands/litentry/get_storage.rs +++ b/tee-worker/identity/cli/src/trusted_base_cli/commands/litentry/get_storage.rs @@ -183,6 +183,10 @@ fn send_get_storage_request( warn!("request status is: {:?}, top_hash: {:?}", status, top_hash); None }, + DirectRequestStatus::Processing(hash) => { + warn!("request status is processing, hash: {:?}", hash); + None + }, } } else { None diff --git a/tee-worker/identity/cli/src/trusted_operation.rs b/tee-worker/identity/cli/src/trusted_operation.rs index 3285f72961..4b1aeda8c8 100644 --- a/tee-worker/identity/cli/src/trusted_operation.rs +++ b/tee-worker/identity/cli/src/trusted_operation.rs @@ -22,7 +22,9 @@ use crate::{ }; use base58::{FromBase58, ToBase58}; use codec::{Decode, Encode, Input}; -use ita_stf::{trusted_call_result::RequestVcResultOrError, Getter, TrustedCallSigned}; +use ita_stf::{ + trusted_call_result::RequestVcResultOrError, Getter, PublicGetter, TrustedCallSigned, +}; use itc_rpc_client::direct_client::{DirectApi, DirectClient}; use itp_node_api::api_client::{ApiClientError, TEEBAG}; use itp_rpc::{Id, RpcRequest, RpcResponse, RpcReturnValue}; @@ -36,7 +38,7 @@ use itp_types::{ DirectRequestStatus, RsaRequest, TrustedOperationStatus, }; use itp_utils::{FromHexPrefixed, ToHexPrefixed}; -use litentry_primitives::{aes_encrypt_default, AesRequest, RequestAesKey}; +use litentry_primitives::{aes_encrypt_default, AesRequest, Identity, RequestAesKey}; use log::*; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use sp_core::H256; @@ -155,6 +157,15 @@ pub(crate) fn get_state( } } +pub(crate) fn get_id_graph_hash( + direct_api: &DirectClient, + shard: &ShardIdentifier, + identity: &Identity, +) -> TrustedOpResult { + let getter = Getter::public(PublicGetter::id_graph_hash(identity.clone())); + get_state(direct_api, *shard, &getter) +} + fn send_indirect_request( cli: &Cli, trusted_args: &TrustedCli, @@ -345,12 +356,20 @@ fn send_direct_request( } }, DirectRequestStatus::Ok => { - debug!("request status is ignored"); + debug!("request status (Ok) is ignored"); direct_api.close().unwrap(); return Err(TrustedOperationError::Default { msg: "Unexpected status: DirectRequestStatus::Ok".to_string(), }) }, + DirectRequestStatus::Processing(hash) => { + debug!("request status (Processing) is ignored, hash: {:?}", hash); + direct_api.close().unwrap(); + return Err(TrustedOperationError::Default { + msg: "Unexpected status: DirectRequestStatus::Processing" + .to_string(), + }) + }, } }; }, @@ -534,7 +553,11 @@ pub(crate) fn wait_until( } }, DirectRequestStatus::Ok => { - debug!("request status is ignored"); + debug!("request status (Ok) is ignored"); + return None + }, + DirectRequestStatus::Processing(hash) => { + debug!("request status (Processing) is ignored, hash: {:?}", hash); return None }, } diff --git a/tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md index a6a530e570..afa0d229d9 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md +++ b/tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +<<<<<<< HEAD +======= ### Changed - Use `@litentry/parachain-api@0.9.20-03.next.0` and `@litentry/sidechain-api@0.9.20-03.next.0` @@ -15,16 +17,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for `Email` Identity +>>>>>>> dev ## [4.2.0] - 2024-08-26 ### Changed +<<<<<<< HEAD +- Use `@litentry/parachain-api@0.9.19-7` +======= - Use `@litentry/parachain-api@0.9.19-7` +>>>>>>> dev ## [4.1.0] - 2024-08-06 ### Added +<<<<<<< HEAD +- Trusted call requests: add the `request.linkIdentityCallback` method. + +### Changed + +- Use `@litentry/parachain-api@0.9.18-11.2` +- `createLitentryIdentityType`: type can now be created by passing a raw value in hex or `Uint8Array` +- `request.requestBatchVc` now support and optional `signer`. + +## [4.0.1] - 2024-07-19 + +- Use `@litentry/parachain-api@0.9.18-11` and `@litentry/sidechain-api@0.9.18-11` stable versions. + +## [4.0.0] - 2024-07-15 + +- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api`. +- Distribute as ES Module +- Targets [parachain-release v0.9.18-10](https://github.com/litentry/litentry-parachain/releases/tag/v0.9.18-10) + +## Added + +- Export the type `IdGraph` and its type's struct name under `ID_GRAPH_STRUCT`. +- Challenge code now produces a prettified string for utf-8 signing for web3 identities when `options.prettify` is set to `true`. + +## Changed + +- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api` por chain types. Deprecates `@litentry/chain-types`. +- Support the new `RequestVcResultOrError` type definition. +- `KeyAesOutput` was renamed to `AesOutput`. +- renamed `global` to `globalThis` +- This library is now distributed as an ESModule + +## Removed + +- Drop `@litentry/chain-types` from dependencies. + +### Fixed + +- `request.getIdGraphHash` no longer throws when the user's id_graph is empty. +======= - Trusted call requests: add the `request.linkIdentityCallback` method. ### Changed @@ -63,29 +110,95 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `request.getIdGraphHash` no longer throws when the user's id_graph is empty. +>>>>>>> dev ## [3.2.1] - 2024-06-10 ### Added +<<<<<<< HEAD +- Adds a new dependency: `@litentry/chaindata`. +======= - Adds a new dependency: `@litentry/chaindata`. +>>>>>>> dev ## [3.1.2] - 2024-06-08 ### Fixed +<<<<<<< HEAD +- Skip `StfError` validation for verifiable credentials requests. Rely on `RequestVcResultOrError` codec. +======= - Skip `StfError` validation for verifiable credentials requests. Rely on `RequestVcResultOrError` codec. +>>>>>>> dev ## [3.1.1] - 2024-06-07 ### Fixed +<<<<<<< HEAD +- Fix error decoding for single assertions request in `request.requestBatchVc`. +======= - Fix error decoding for single assertions request in `request.requestBatchVc`. +>>>>>>> dev ## [3.1.0] - 2024-06-03 ### Changed +<<<<<<< HEAD +- Upgrade `@polkadot/api*`, `@polkadot/rpc*`, `@polkadot/types*` to 10.9.1, and `@polkadot/util*` to `12.5.1` + +### Removed + +- Drop unused `@polkadot/keyring` dependency. + +## [3.0.0] - 2024-06-03 + +- Introduce oAuth2 proofs support for Web2 identity validation + +### Added + +- Config: support `litentry-staging` for the env var `[NX_]PARACHAIN_NETWORK`. +- Config: support the new env var `[NX_]LITENTRY_NETWORK` for setting the network same as `[NX_]PARACHAIN_NETWORK` but higher precedence. +- Config: accept custom WS endpoints on `[NX_]LITENTRY_NETWORK` / `[NX_]PARACHAIN_NETWORK`. + +### Changed + +- Use `@litentry/chain-types@2.0.0` +- The type creator `createLitentryValidationDataType` now accepts building oAuth2 proofs for Discord and Twitter. + + ```ts + // twitter + const twitterOAuth2Proof = createLitentryValidationDataType( + registry, + { + addressOrHandle: 'my_twitter_handle', + type: 'Twitter', + }, + { + code: 'my_twitter_code', + state: 'my_twitter_state', + redirectUri: 'http://test-redirect-uri', + } + ); + + // Discord + const validationData = createLitentryValidationDataType( + registry, + { + addressOrHandle: 'my_discord_handle', + type: 'Discord', + }, + { + code: 'my_discord_code', + redirectUri: 'http://test-redirect-uri', + } + ); + ``` + + The legacy public message proofs are still supported. +======= - Upgrade `@polkadot/api*`, `@polkadot/rpc*`, `@polkadot/types*` to 10.9.1, and `@polkadot/util*` to `12.5.1` ### Removed @@ -137,17 +250,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ``` The legacy public message proofs are still supported. +>>>>>>> dev ## [2.0.1] - 2024-05-21 ### Changed +<<<<<<< HEAD +- When no `PARACHAIN_NETWORK` or `NX_PARACHAIN_NETWORK` is specified, the library will default to the production (`tee-prod`) endpoint rather than to development (`tee-dev`). +======= - When no `PARACHAIN_NETWORK` or `NX_PARACHAIN_NETWORK` is specified, the library will default to the production (`tee-prod`) endpoint rather than to development (`tee-dev`). +>>>>>>> dev ## [2.0.0] - 2024-05-17 ### Removed +<<<<<<< HEAD +- `createLitentryIdentityType` dropped the support deriving the identity type from the provided address. Now both `addressOrHandle` and `type` are required. + + ```ts + import { createLitentryIdentityType } from '@litentry/enclave'; + + // from + createLitentryIdentityType(registry, { + address: '5DNx1Kgis2u2SQq7EJrBdnV49PoZCxV3NqER4vV5VqjqZcat', + }); + + // To + createLitentryIdentityType(registry, { + addressOrHandle: '5DNx1Kgis2u2SQq7EJrBdnV49PoZCxV3NqER4vV5VqjqZcat', + type: 'Substrate', + }); + ``` + + consequently, the following methods require a `LitentryIdentity` for the `who` parameter instead of a plain address string: `request.getIdGraph`, `request.linkIdentity`, `request.requestBatchVc`, `request.setIdentityNetworks`, and `request.createChallengeCode`. +======= - `createLitentryIdentityType` dropped the support deriving the identity type from the provided address. Now both `addressOrHandle` and `type` are required. ```ts @@ -166,6 +304,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ``` consequently, the following methods require a `LitentryIdentity` for the `who` parameter instead of a plain address string: `request.getIdGraph`, `request.linkIdentity`, `request.requestBatchVc`, `request.setIdentityNetworks`, and `request.createChallengeCode`. +>>>>>>> dev ## [1.0.4] - 2024-05-16 @@ -175,13 +314,21 @@ Routinely update ### Changed +<<<<<<< HEAD +- `@litentry/enclave` add support for Solana hex-encoded signatures. It hex string is not provided, it will default to base58 decoding. +======= - `@litentry/enclave` add support for Solana hex-encoded signatures. It hex string is not provided, it will default to base58 decoding. +>>>>>>> dev ## [1.0.2] - 2024-05-14 ### Changed +<<<<<<< HEAD +- `@litentry/chain-types` is now marked as a peerDependency +======= - `@litentry/chain-types` is now marked as a peerDependency +>>>>>>> dev ## [1.0.1] - 2024-05-08 @@ -189,6 +336,31 @@ Routinely update ## [1.0.0] - 2024-04-24 +<<<<<<< HEAD +- Initial public version + +### Added + +- Request methods that mutate the idGraph information will have a common response. The entire idGraph will no longer be returned but the information about the updated identity only. +- `request.getIdGraphHash` Request getter to get idGraph hash with no signature. +- `calculateIdGraphHash`: Helper method to calculate the hash of a given local idGraph. +- `request.requestBatchVC`: Request trusted call to request a batch of VCs. +- `Enclave.send` now supports a third argument to subscribe to the WS streamed responses. +- Payload signature is now beautify by default to look more human. +- Use a different key for encrypting the transmitted package to the Enclave. + +### Removed + +- `request.requestVc`. Superseded by `request.requestBatchVc`. +- `createEnclaveHttpProxyHandler`. The connection to the Enclave is now done directly via WebSockets. + +### Changed + +- Migrate from `teerex` to `teebag`. +- Enclave's nonce is now retrieved through the `author_getNextNonce` getter call. +- The connection to the Enclave is now done directly via WebSockets. Setting up an HTTP proxy is no longer necessary nor suggested. +- The payload size of all operations was reduced and fixed to a 32-bytes length. +======= - Initial public version ### Added @@ -212,6 +384,7 @@ Routinely update - Enclave's nonce is now retrieved through the `author_getNextNonce` getter call. - The connection to the Enclave is now done directly via WebSockets. Setting up an HTTP proxy is no longer necessary nor suggested. - The payload size of all operations was reduced and fixed to a 32-bytes length. +>>>>>>> dev ## 2023-12-05 @@ -219,6 +392,29 @@ Update to `Litentry-parachain p0.9.17-9170-w0.0.1-100`. ### Added +<<<<<<< HEAD +- `request.getIdGraph`: fetch the user's idGraph from the Enclave Sidechain. It requires user signature. + +### Changed + +- **Shielding key**: Users no longer need to set a shielding key on-chain. The data for network transportation is now protected by ephemeral shielding keys generated on the fly. Ephemeral shielding keys increase security and enhance the user experience. +- **Direct responses**: Operation responses are no longer gathered from the Parachain but from the Enclave itself. +- `request.linkIdentity`: The method now has a two level encryption: the information is encrypted with a different key that the one used for transportation. +- `request.linkIdentity`: The call argument `data.encryptionNonce` was removed. +- `request.linkIdentity`: The returned `send` callback now returns both the idGraph and the parsed sidechain response in a `WorkerRpcReturnValue` type. +- `request.createChallengeCode`: The call argument `args.shield` was removed. The Challenge code no longer needs encrypted information. +- `request.setIdentityNetworks`: The returned `send` callback now returns the transaction hash `txHash` and the parsed sidechain response in a `WorkerRpcReturnValue` type. +- `request.requestVc`: The returned `send` callback now returns the `vcIndex`, `vcHash` and the VC's contents on `vcPayload`. As well as the parsed sidechain response in a `WorkerRpcReturnValue` type. +- `enclave.getNonce` was moved as a requestor: `request.getEnclaveNonce`. +- `KeyAesOutput` type is no longer part of the Parachain-runtime metadata and thus it can't be found on `@polkadot/types/lookup`. Use `KeyAesOutput` instead from `@litentry/chain-types` +- `enclave.send`: Error thrown during Enclave operations include more information now. +- `createEnclaveHttpProxyHandler`: HTTP errors responses are now only returned if reaching the Enclave or processing the request fails. However, `enclave.send` could still throw an execution error if the intrinsic operation contains errors. For instance, linking an already linked identity will result on a 200 HTTP response from the Enclave's proxy but `enclave.send` will throw an error about `IdentityAlreadyLinked`. + +### Removed + +- `request.setUserShieldingKey`: It is no longer needed to set the user's shielding key on-chain. See the Shielding Key point on the Changed section for more information. +- `ky-universal` dependency was dropped. +======= - `request.getIdGraph`: fetch the user's idGraph from the Enclave Sidechain. It requires user signature. ### Changed @@ -240,6 +436,7 @@ Update to `Litentry-parachain p0.9.17-9170-w0.0.1-100`. - `request.setUserShieldingKey`: It is no longer needed to set the user's shielding key on-chain. See the Shielding Key point on the Changed section for more information. - `ky-universal` dependency was dropped. +>>>>>>> dev ## 2023-11-01 diff --git a/tee-worker/identity/core-primitives/attestation-handler/AttestationReportSigningCACert.pem b/tee-worker/identity/core-primitives/attestation-handler/AttestationReportSigningCACert.pem deleted file mode 100644 index 948b4c0cdd..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/AttestationReportSigningCACert.pem +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFSzCCA7OgAwIBAgIJANEHdl0yo7CUMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNV -BAYTAlVTMQswCQYDVQQIDAJDQTEUMBIGA1UEBwwLU2FudGEgQ2xhcmExGjAYBgNV -BAoMEUludGVsIENvcnBvcmF0aW9uMTAwLgYDVQQDDCdJbnRlbCBTR1ggQXR0ZXN0 -YXRpb24gUmVwb3J0IFNpZ25pbmcgQ0EwIBcNMTYxMTE0MTUzNzMxWhgPMjA0OTEy -MzEyMzU5NTlaMH4xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEUMBIGA1UEBwwL -U2FudGEgQ2xhcmExGjAYBgNVBAoMEUludGVsIENvcnBvcmF0aW9uMTAwLgYDVQQD -DCdJbnRlbCBTR1ggQXR0ZXN0YXRpb24gUmVwb3J0IFNpZ25pbmcgQ0EwggGiMA0G -CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCfPGR+tXc8u1EtJzLA10Feu1Wg+p7e -LmSRmeaCHbkQ1TF3Nwl3RmpqXkeGzNLd69QUnWovYyVSndEMyYc3sHecGgfinEeh -rgBJSEdsSJ9FpaFdesjsxqzGRa20PYdnnfWcCTvFoulpbFR4VBuXnnVLVzkUvlXT -L/TAnd8nIZk0zZkFJ7P5LtePvykkar7LcSQO85wtcQe0R1Raf/sQ6wYKaKmFgCGe -NpEJUmg4ktal4qgIAxk+QHUxQE42sxViN5mqglB0QJdUot/o9a/V/mMeH8KvOAiQ -byinkNndn+Bgk5sSV5DFgF0DffVqmVMblt5p3jPtImzBIH0QQrXJq39AT8cRwP5H -afuVeLHcDsRp6hol4P+ZFIhu8mmbI1u0hH3W/0C2BuYXB5PC+5izFFh/nP0lc2Lf -6rELO9LZdnOhpL1ExFOq9H/B8tPQ84T3Sgb4nAifDabNt/zu6MmCGo5U8lwEFtGM -RoOaX4AS+909x00lYnmtwsDVWv9vBiJCXRsCAwEAAaOByTCBxjBgBgNVHR8EWTBX -MFWgU6BRhk9odHRwOi8vdHJ1c3RlZHNlcnZpY2VzLmludGVsLmNvbS9jb250ZW50 -L0NSTC9TR1gvQXR0ZXN0YXRpb25SZXBvcnRTaWduaW5nQ0EuY3JsMB0GA1UdDgQW -BBR4Q3t2pn680K9+QjfrNXw7hwFRPDAfBgNVHSMEGDAWgBR4Q3t2pn680K9+Qjfr -NXw7hwFRPDAOBgNVHQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBADANBgkq -hkiG9w0BAQsFAAOCAYEAeF8tYMXICvQqeXYQITkV2oLJsp6J4JAqJabHWxYJHGir -IEqucRiJSSx+HjIJEUVaj8E0QjEud6Y5lNmXlcjqRXaCPOqK0eGRz6hi+ripMtPZ -sFNaBwLQVV905SDjAzDzNIDnrcnXyB4gcDFCvwDFKKgLRjOB/WAqgscDUoGq5ZVi -zLUzTqiQPmULAQaB9c6Oti6snEFJiCQ67JLyW/E83/frzCmO5Ru6WjU4tmsmy8Ra -Ud4APK0wZTGtfPXU7w+IBdG5Ez0kE1qzxGQaL4gINJ1zMyleDnbuS8UicjJijvqA -152Sq049ESDz+1rRGc2NVEqh1KaGXmtXvqxXcTB+Ljy5Bw2ke0v8iGngFBPqCTVB -3op5KBG3RjbF6RRSzwzuWfL7QErNC8WEy5yDVARzTA5+xmBc388v9Dm21HGfcC8O -DD+gT9sSpssq0ascmvH49MOgjt1yoysLtdCtJW/9FZpoOypaHx0R+mJTLwPXVMrv -DaVzWh5aiEx+idkSGMnX ------END CERTIFICATE----- diff --git a/tee-worker/identity/core-primitives/attestation-handler/Cargo.toml b/tee-worker/identity/core-primitives/attestation-handler/Cargo.toml deleted file mode 100644 index a573ddc1aa..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/Cargo.toml +++ /dev/null @@ -1,102 +0,0 @@ -[package] -name = "itp-attestation-handler" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates-io no_std deps -arrayvec = { version = "0.7.1", default-features = false } -bit-vec = { version = "0.6", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -itertools = { default-features = false, version = "0.10.1" } -log = { version = "0.4", default-features = false } - -# std only deps -base64 = { version = "0.13", features = ["alloc"], optional = true } -chrono = { version = "0.4.19", features = ["alloc"], optional = true } -rustls = { version = "0.19", optional = true } -serde_json = { version = "1.0", features = ["preserve_order"], optional = true } -thiserror = { version = "1.0", optional = true } -webpki = { version = "0.21", optional = true } - -# mesalock -base64_sgx = { package = "base64", rev = "sgx_1.1.3", git = "https://github.com/mesalock-linux/rust-base64-sgx", optional = true } -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -num-bigint = { optional = true, git = "https://github.com/mesalock-linux/num-bigint-sgx" } -rustls_sgx = { package = "rustls", rev = "sgx_1.1.3", features = ["dangerous_configuration"], git = "https://github.com/mesalock-linux/rustls", optional = true } -serde_json_sgx = { package = "serde_json", tag = "sgx_1.1.3", features = ["preserve_order"], git = "https://github.com/mesalock-linux/serde-json-sgx", optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } -webpki-roots = { git = "https://github.com/mesalock-linux/webpki-roots", branch = "mesalock_sgx" } -webpki_sgx = { package = "webpki", git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx", optional = true } -yasna_sgx = { package = "yasna", optional = true, default-features = false, features = ["bit-vec", "num-bigint", "chrono", "mesalock_sgx"], git = "https://github.com/mesalock-linux/yasna.rs-sgx", rev = "sgx_1.1.3" } - -# sgx -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tcrypto = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tse = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["untrusted_fs", "net", "backtrace"], optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["extra_traits"] } - -# local deps -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-settings = { path = "../settings" } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-io = { path = "../sgx/io", default-features = false } -itp-time-utils = { path = "../time-utils", default-features = false } - -# integritee -httparse = { default-features = false, git = "https://github.com/integritee-network/httparse-sgx", branch = "sgx-experimental" } - -# substrate deps -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - # crates-io no_std - "arrayvec/std", - "codec/std", - "hex/std", - "log/std", - "itertools/use_std", - # optional std only - "base64", - "chrono", - "rustls", - "serde_json", - "thiserror", - "webpki", - # local - "itp-ocall-api/std", - "itp-sgx-io/std", - "itp-sgx-crypto/std", - # substrate - "sp-core/std", - # integritee - "httparse/std", -] - -sgx = [ - # sgx-only - "base64_sgx", - "chrono_sgx", - "rustls_sgx", - "serde_json_sgx", - "thiserror_sgx", - "webpki_sgx", - "yasna_sgx", - "sgx_tse", - "sgx_tstd", - "sgx_rand", - "sgx_tcrypto", - "num-bigint", - # local - "itp-sgx-io/sgx", - "itp-sgx-crypto/sgx", - # integritee - "httparse/mesalock_sgx", -] -test = [] -development = [] diff --git a/tee-worker/identity/core-primitives/attestation-handler/src/cert.rs b/tee-worker/identity/core-primitives/attestation-handler/src/cert.rs deleted file mode 100644 index 7d1a2d6064..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/src/cert.rs +++ /dev/null @@ -1,497 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{Error as EnclaveError, Result as EnclaveResult}; -use arrayvec::ArrayVec; -use chrono::DateTime; -use itertools::Itertools; -use itp_ocall_api::EnclaveAttestationOCallApi; -use log::*; -use serde_json::Value; -use sgx_types::{ - sgx_platform_info_t, sgx_quote_t, sgx_status_t, SgxResult, SGX_PLATFORM_INFO_SIZE, -}; -use std::{ - io::BufReader, - ptr, str, - string::String, - time::{SystemTime, UNIX_EPOCH}, - vec::Vec, -}; - -type SignatureAlgorithms = &'static [&'static webpki::SignatureAlgorithm]; -static SUPPORTED_SIG_ALGS: SignatureAlgorithms = &[ - &webpki::ECDSA_P256_SHA256, - &webpki::ECDSA_P256_SHA384, - &webpki::ECDSA_P384_SHA256, - &webpki::ECDSA_P384_SHA384, - &webpki::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, - &webpki::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, - &webpki::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, - &webpki::RSA_PKCS1_2048_8192_SHA256, - &webpki::RSA_PKCS1_2048_8192_SHA384, - &webpki::RSA_PKCS1_2048_8192_SHA512, - &webpki::RSA_PKCS1_3072_8192_SHA384, -]; - -pub const CERTEXPIRYDAYS: i64 = 90i64; -pub const IAS_REPORT_CA: &[u8] = include_bytes!("../AttestationReportSigningCACert.pem"); - -#[cfg(feature = "sgx")] -pub use sgx::*; - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::*; - use bit_vec::BitVec; - use chrono::{Duration, TimeZone, Utc as TzUtc}; - use num_bigint::BigUint; - use sgx_tcrypto::SgxEccHandle; - use sgx_types::{sgx_ec256_private_t, sgx_ec256_public_t}; - use yasna::models::ObjectIdentifier; - - const ISSUER: &str = "Integritee"; - const SUBJECT: &str = "Integritee ephemeral"; - - /// `payload` must be a valid a string, not just arbitrary data. - pub fn gen_ecc_cert( - payload: &str, - prv_k: &sgx_ec256_private_t, - pub_k: &sgx_ec256_public_t, - ecc_handle: &SgxEccHandle, - ) -> Result<(Vec, Vec), sgx_status_t> { - // Generate public key bytes since both DER will use it - let mut pub_key_bytes: Vec = vec![4]; - let mut pk_gx = pub_k.gx; - pk_gx.reverse(); - let mut pk_gy = pub_k.gy; - pk_gy.reverse(); - pub_key_bytes.extend_from_slice(&pk_gx); - pub_key_bytes.extend_from_slice(&pk_gy); - - // Generate Certificate DER - let cert_der = yasna::construct_der(|writer| { - writer.write_sequence(|writer| { - writer.next().write_sequence(|writer| { - // Certificate Version - writer.next().write_tagged(yasna::Tag::context(0), |writer| { - writer.write_i8(2); - }); - // Certificate Serial Number (unused but required) - writer.next().write_u8(1); - // Signature Algorithm: ecdsa-with-SHA256 - writer.next().write_sequence(|writer| { - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[1, 2, 840, 10045, 4, 3, 2])); - }); - // Issuer: CN=MesaTEE (unused but required) - writer.next().write_sequence(|writer| { - writer.next().write_set(|writer| { - writer.next().write_sequence(|writer| { - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[2, 5, 4, 3])); - writer.next().write_utf8_string(ISSUER); - }); - }); - }); - // Validity: Issuing/Expiring Time (unused but required) - let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); - let issue_ts = TzUtc.timestamp(now.as_secs() as i64, 0); - let expire = now + Duration::days(CERTEXPIRYDAYS).to_std().unwrap(); - let expire_ts = TzUtc.timestamp(expire.as_secs() as i64, 0); - writer.next().write_sequence(|writer| { - writer - .next() - .write_utctime(&yasna::models::UTCTime::from_datetime(&issue_ts)); - writer - .next() - .write_utctime(&yasna::models::UTCTime::from_datetime(&expire_ts)); - }); - // Subject: CN=MesaTEE (unused but required) - writer.next().write_sequence(|writer| { - writer.next().write_set(|writer| { - writer.next().write_sequence(|writer| { - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[2, 5, 4, 3])); - writer.next().write_utf8_string(SUBJECT); - }); - }); - }); - writer.next().write_sequence(|writer| { - // Public Key Algorithm - writer.next().write_sequence(|writer| { - // id-ecPublicKey - writer.next().write_oid(&ObjectIdentifier::from_slice(&[ - 1, 2, 840, 10045, 2, 1, - ])); - // prime256v1 - writer.next().write_oid(&ObjectIdentifier::from_slice(&[ - 1, 2, 840, 10045, 3, 1, 7, - ])); - }); - // Public Key - writer.next().write_bitvec(&BitVec::from_bytes(&pub_key_bytes)); - }); - // Certificate V3 Extension - writer.next().write_tagged(yasna::Tag::context(3), |writer| { - writer.write_sequence(|writer| { - writer.next().write_sequence(|writer| { - writer.next().write_oid(&ObjectIdentifier::from_slice(&[ - 2, 16, 840, 1, 113_730, 1, 13, - ])); - writer.next().write_bytes(payload.as_bytes()); - }); - }); - }); - }); - // Signature Algorithm: ecdsa-with-SHA256 - writer.next().write_sequence(|writer| { - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[1, 2, 840, 10045, 4, 3, 2])); - }); - // Signature - let sig = { - let tbs = &writer.buf[4..]; - ecc_handle.ecdsa_sign_slice(tbs, prv_k).unwrap() - }; - let sig_der = yasna::construct_der(|writer| { - writer.write_sequence(|writer| { - let mut sig_x = sig.x; - sig_x.reverse(); - let mut sig_y = sig.y; - sig_y.reverse(); - writer.next().write_biguint(&BigUint::from_slice(&sig_x)); - writer.next().write_biguint(&BigUint::from_slice(&sig_y)); - }); - }); - writer.next().write_bitvec(&BitVec::from_bytes(&sig_der)); - }); - }); - - // Generate Private Key DER - let key_der = yasna::construct_der(|writer| { - writer.write_sequence(|writer| { - writer.next().write_u8(0); - writer.next().write_sequence(|writer| { - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[1, 2, 840, 10045, 2, 1])); - writer - .next() - .write_oid(&ObjectIdentifier::from_slice(&[1, 2, 840, 10045, 3, 1, 7])); - }); - let inner_key_der = yasna::construct_der(|writer| { - writer.write_sequence(|writer| { - writer.next().write_u8(1); - let mut prv_k_r = prv_k.r; - prv_k_r.reverse(); - writer.next().write_bytes(&prv_k_r); - writer.next().write_tagged(yasna::Tag::context(1), |writer| { - writer.write_bitvec(&BitVec::from_bytes(&pub_key_bytes)); - }); - }); - }); - writer.next().write_bytes(&inner_key_der); - }); - }); - - Ok((key_der, cert_der)) - } -} - -pub fn percent_decode(orig: String) -> EnclaveResult { - let v: Vec<&str> = orig.split('%').collect(); - let mut ret = String::new(); - ret.push_str(v[0]); - if v.len() > 1 { - for s in v[1..].iter() { - ret.push(u8::from_str_radix(&s[0..2], 16).map_err(|e| EnclaveError::Other(e.into()))? - as char); - ret.push_str(&s[2..]); - } - } - Ok(ret) -} - -pub fn parse_cert_issuer(cert_der: &[u8]) -> SgxResult> { - // Before we reach here, Webpki already verified the cert is properly signed - - // Search for Public Key prime256v1 OID - let prime256v1_oid = &[0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]; - let mut offset = cert_der - .windows(prime256v1_oid.len()) - .position(|window| window == prime256v1_oid) - .ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - offset += 11; // 10 + TAG (0x03) - - // Obtain Public Key length - let mut len = cert_der[offset] as usize; - if len > 0x80 { - len = (cert_der[offset + 1] as usize) * 0x100 + (cert_der[offset + 2] as usize); - offset += 2; - } - - // Obtain Public Key - offset += 1; - let pub_k = cert_der[offset + 2..offset + len].to_vec(); // skip "00 04" - - Ok(pub_k) -} - -// FIXME: This code is redundant with the host call of the integritee-node -pub fn verify_mra_cert( - cert_der: &[u8], - is_payload_base64_encoded: bool, - is_dcap: bool, - attestation_ocall: &A, -) -> SgxResult<()> -where - A: EnclaveAttestationOCallApi, -{ - // Before we reach here, Webpki already verified the cert is properly signed - - // Search for Public Key prime256v1 OID - let prime256v1_oid = &[0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]; - let mut offset = cert_der - .windows(prime256v1_oid.len()) - .position(|window| window == prime256v1_oid) - .ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - offset += 11; // 10 + TAG (0x03) - - // Obtain Public Key length - let mut len = cert_der[offset] as usize; - if len > 0x80 { - len = (cert_der[offset + 1] as usize) * 0x100 + (cert_der[offset + 2] as usize); - offset += 2; - } - - // Obtain Public Key - offset += 1; - let pub_k = cert_der[offset + 2..offset + len].to_vec(); // skip "00 04" - - // Search for Netscape Comment OID - let ns_cmt_oid = &[0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x42, 0x01, 0x0D]; - let mut offset = cert_der - .windows(ns_cmt_oid.len()) - .position(|window| window == ns_cmt_oid) - .ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - offset += 12; // 11 + TAG (0x04) - - // Obtain Netscape Comment length - let mut len = cert_der[offset] as usize; - if len > 0x80 { - len = (cert_der[offset + 1] as usize) * 0x100 + (cert_der[offset + 2] as usize); - offset += 2; - } - - // Obtain Netscape Comment - offset += 1; - let mut payload = cert_der[offset..offset + len].to_vec(); - trace!("payload in mra cert verifier is: {:?}", &payload); - if is_payload_base64_encoded { - payload = base64::decode(&payload[..]).or(Err(sgx_status_t::SGX_ERROR_UNEXPECTED))?; - } - trace!("payload in mra cert verifier is: {:?}", &payload); - if !is_dcap { - // Extract each field - let mut iter = payload.split(|x| *x == b'|'); - let attn_report_raw = iter.next().ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - let sig_raw = iter.next().ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - let sig = base64::decode(sig_raw).map_err(|e| EnclaveError::Other(e.into()))?; - - let sig_cert_raw = iter.next().ok_or(sgx_status_t::SGX_ERROR_UNEXPECTED)?; - let sig_cert_dec = base64::decode_config(sig_cert_raw, base64::STANDARD) - .map_err(|e| EnclaveError::Other(e.into()))?; - let sig_cert = webpki::EndEntityCert::from(&sig_cert_dec).expect("Bad DER"); - - // Verify if the signing cert is issued by Intel CA - let mut ias_ca_stripped = IAS_REPORT_CA.to_vec(); - ias_ca_stripped.retain(|&x| x != b'\r' && x != b'\n'); - let head_len = "-----BEGIN CERTIFICATE-----".len(); - let tail_len = "-----END CERTIFICATE-----".len(); - let full_len = ias_ca_stripped.len(); - let ias_ca_core: &[u8] = &ias_ca_stripped[head_len..full_len - tail_len]; - let ias_cert_dec = base64::decode_config(ias_ca_core, base64::STANDARD) - .map_err(|e| EnclaveError::Other(e.into()))?; - - let mut ca_reader = BufReader::new(IAS_REPORT_CA); - - let mut root_store = rustls::RootCertStore::empty(); - root_store.add_pem_file(&mut ca_reader).expect("Failed to add CA"); - - let trust_anchors: Vec = - root_store.roots.iter().map(|cert| cert.to_trust_anchor()).collect(); - - let now_func = webpki::Time::try_from(SystemTime::now()); - - match sig_cert.verify_is_valid_tls_server_cert( - SUPPORTED_SIG_ALGS, - &webpki::TLSServerTrustAnchors(&trust_anchors), - &[ias_cert_dec.as_slice()], - now_func.map_err(|_e| EnclaveError::Time)?, - ) { - Ok(_) => info!("Cert is good"), - Err(e) => { - error!("Cert verification error {:?}", e); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - }, - } - - // Verify the signature against the signing cert - match sig_cert.verify_signature(&webpki::RSA_PKCS1_2048_8192_SHA256, attn_report_raw, &sig) - { - Ok(_) => info!("Signature good"), - Err(e) => { - error!("Signature verification error {:?}", e); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - }, - } - - verify_attn_report(attn_report_raw, pub_k, attestation_ocall) - } else { - // TODO Refactor state provisioning to not use MURA #1385 - // TODO DCAP is currently just passed through! SECURITY!!! - Ok(()) - } -} - -pub fn verify_attn_report( - report_raw: &[u8], - pub_k: Vec, - attestation_ocall: &A, -) -> SgxResult<()> -where - A: EnclaveAttestationOCallApi, -{ - // Verify attestation report - // 1. Check timestamp is within 24H (90day is recommended by Intel) - let attn_report: Value = - serde_json::from_slice(report_raw).map_err(|e| EnclaveError::Other(e.into()))?; - if let Value::String(time) = &attn_report["timestamp"] { - let time_fixed = time.clone() + "+0000"; - let ts = DateTime::parse_from_str(&time_fixed, "%Y-%m-%dT%H:%M:%S%.f%z") - .map_err(|e| EnclaveError::Other(e.into()))? - .timestamp(); - let now = SystemTime::now() - .duration_since(UNIX_EPOCH) - .map_err(|e| EnclaveError::Other(e.into()))? - .as_secs() as i64; - info!("Time diff = {}", now - ts); - } else { - error!("Failed to fetch timestamp from attestation report"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - // 2. Verify quote status (mandatory field) - if let Value::String(quote_status) = &attn_report["isvEnclaveQuoteStatus"] { - debug!("isvEnclaveQuoteStatus = {}", quote_status); - match quote_status.as_ref() { - "OK" => (), - "SW_HARDENING_NEEDED" => info!("Status in attestation report is SW_HARDENING_NEEDED, which is considered acceptable."), - "GROUP_OUT_OF_DATE" | "GROUP_REVOKED" | "CONFIGURATION_NEEDED" => { - // Verify platformInfoBlob for further info if status not OK - if let Value::String(pib) = &attn_report["platformInfoBlob"] { - let mut buf = ArrayVec::<_, SGX_PLATFORM_INFO_SIZE>::new(); - - // the TLV Header (4 bytes/8 hexes) should be skipped - let n = (pib.len() - 8) / 2; - for i in 0..n { - buf.try_push( - u8::from_str_radix(&pib[(i * 2 + 8)..(i * 2 + 10)], 16) - .map_err(|e| EnclaveError::Other(e.into()))?, - ) - .map_err(|e| { - error!("failed to push element to platform info blob buffer, exceeding buffer size ({})", e); - sgx_status_t::SGX_ERROR_UNEXPECTED - })?; - } - - // ArrayVec .into_inner() requires that all elements are occupied by a value - // if that's not the case, the following error will occur - let platform_info = buf.into_inner().map_err(|e| { - error!("Failed to extract platform info from InfoBlob, result does not contain enough elements (require: {}, found: {})", e.capacity(), e.len()); - sgx_status_t::SGX_ERROR_UNEXPECTED - })?; - - attestation_ocall.get_update_info(sgx_platform_info_t { platform_info }, 1)?; - } else { - error!("Failed to fetch platformInfoBlob from attestation report"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - }, - status => { - error!("Unexpected status in attestation report: {}", status); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - }, - } - } else { - error!("Failed to fetch isvEnclaveQuoteStatus from attestation report"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - // 3. Verify quote body - if let Value::String(quote_raw) = &attn_report["isvEnclaveQuoteBody"] { - let quote = base64::decode(quote_raw).map_err(|e| EnclaveError::Other(e.into()))?; - debug!("Quote = {:?}", quote); - // TODO: lack security check here - let sgx_quote: sgx_quote_t = unsafe { ptr::read(quote.as_ptr() as *const _) }; - - let ti = attestation_ocall.get_mrenclave_of_self()?; - if sgx_quote.report_body.mr_enclave.m != ti.m { - error!( - "mr_enclave is not equal to self {:?} != {:?}", - sgx_quote.report_body.mr_enclave.m, ti.m - ); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - // ATTENTION - // DO SECURITY CHECK ON DEMAND - // DO SECURITY CHECK ON DEMAND - // DO SECURITY CHECK ON DEMAND - - // Curly braces to copy `unaligned_references` of packed fields into properly aligned temporary: - // https://github.com/rust-lang/rust/issues/82523 - debug!("sgx quote version = {}", { sgx_quote.version }); - debug!("sgx quote signature type = {}", { sgx_quote.sign_type }); - debug!( - "sgx quote report_data = {:02x}", - sgx_quote.report_body.report_data.d.iter().format("") - ); - debug!( - "sgx quote mr_enclave = {:02x}", - sgx_quote.report_body.mr_enclave.m.iter().format("") - ); - debug!("sgx quote mr_signer = {:02x}", sgx_quote.report_body.mr_signer.m.iter().format("")); - debug!("Anticipated public key = {:02x}", pub_k.iter().format("")); - if sgx_quote.report_body.report_data.d.to_vec() == pub_k.to_vec() { - info!("Mutual RA done!"); - } - } else { - error!("Failed to fetch isvEnclaveQuoteBody from attestation report"); - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED) - } - - Ok(()) -} diff --git a/tee-worker/identity/core-primitives/attestation-handler/src/collateral.rs b/tee-worker/identity/core-primitives/attestation-handler/src/collateral.rs deleted file mode 100644 index a4713c5c94..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/src/collateral.rs +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright 2022 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::serde_json; -use sgx_types::sgx_ql_qve_collateral_t; -use std::{io::Write, string::String, vec::Vec}; - -/// This is a rust-ified version of the type sgx_ql_qve_collateral_t. -/// See Appendix A.3 in the document -/// "Intel® Software Guard Extensions (Intel® SGX) Data Center Attestation Primitives: ECDSA Quote Library API" -/// https://download.01.org/intel-sgx/latest/dcap-latest/linux/docs/Intel_SGX_ECDSA_QuoteLibReference_DCAP_API.pdf -pub struct SgxQlQveCollateral { - pub version: u32, // version = 1. PCK Cert chain is in the Quote. - /* intel DCAP 1.13 */ - pub tee_type: u32, // 0x00000000: SGX or 0x00000081: TDX - pub pck_crl_issuer_chain: Vec, - pub root_ca_crl: Vec, - pub pck_crl: Vec, - pub tcb_info_issuer_chain: Vec, - pub tcb_info: Vec, - pub qe_identity_issuer_chain: Vec, - pub qe_identity: Vec, -} - -impl SgxQlQveCollateral { - /// # Safety - /// - /// The caller is in charge of ensuring that `c` is properly initialized and all - /// its members have a value that is not nullptr - pub unsafe fn from_c_type(c: &sgx_ql_qve_collateral_t) -> Self { - let pck_crl_issuer_chain = std::slice::from_raw_parts( - c.pck_crl_issuer_chain as *const u8, - c.pck_crl_issuer_chain_size as usize, - ) - .to_vec(); - let root_ca_crl = - std::slice::from_raw_parts(c.root_ca_crl as *const u8, c.root_ca_crl_size as usize) - .to_vec(); - let pck_crl = - std::slice::from_raw_parts(c.pck_crl as *const u8, c.pck_crl_size as usize).to_vec(); - let tcb_info_issuer_chain = std::slice::from_raw_parts( - c.tcb_info_issuer_chain as *const u8, - c.tcb_info_issuer_chain_size as usize, - ) - .to_vec(); - let tcb_info = - std::slice::from_raw_parts(c.tcb_info as *const u8, c.tcb_info_size as usize).to_vec(); - let qe_identity_issuer_chain = std::slice::from_raw_parts( - c.qe_identity_issuer_chain as *const u8, - c.qe_identity_issuer_chain_size as usize, - ) - .to_vec(); - let qe_identity = - std::slice::from_raw_parts(c.qe_identity as *const u8, c.qe_identity_size as usize) - .to_vec(); - SgxQlQveCollateral { - version: c.version, - tee_type: c.tee_type, - pck_crl_issuer_chain, - root_ca_crl, - pck_crl, - tcb_info_issuer_chain, - tcb_info, - qe_identity_issuer_chain, - qe_identity, - } - } - - pub fn dump_to_disk(&self) { - Self::write_data_to_disk("pck_crl_issuer_chain", &self.pck_crl_issuer_chain); - Self::write_data_to_disk("root_ca_crl", &self.root_ca_crl); - Self::write_data_to_disk("pck_crl", &self.pck_crl); - Self::write_data_to_disk("tcb_info_issuer_chain", &self.tcb_info_issuer_chain); - Self::write_data_to_disk("tcb_info", &self.tcb_info); - Self::write_data_to_disk("qe_identity_issuer_chain", &self.qe_identity_issuer_chain); - Self::write_data_to_disk("qe_identity", &self.qe_identity); - } - - /// Returns the tcb_info split into two parts: json_data and signature - pub fn get_tcb_info_split(&self) -> Option<(String, Vec)> { - let (json_data, signature) = - Self::separate_json_data_and_signature("tcbInfo", &self.tcb_info)?; - match hex::decode(signature) { - Ok(hex_signature) => Some((json_data, hex_signature)), - Err(_) => None, - } - } - - /// Returns the tcb_info split into two parts: json_data and signature - pub fn get_quoting_enclave_split(&self) -> Option<(String, Vec)> { - let (json_data, signature) = - Self::separate_json_data_and_signature("enclaveIdentity", &self.qe_identity)?; - match hex::decode(signature) { - Ok(hex_signature) => Some((json_data, hex_signature)), - Err(_) => None, - } - } - - /// Separates the actual data part from the signature for an Intel collateral in JSON format - /// Returns the data part and signature as a pair - fn separate_json_data_and_signature(data_name: &str, data: &[u8]) -> Option<(String, String)> { - let json = String::from_utf8_lossy(data); - // Remove potential C-style null terminators - let json = json.trim_matches(char::from(0)); - let value: serde_json::Value = serde_json::from_str(json).ok()?; - if value[data_name].is_null() || value["signature"].is_null() { - return None - } - let data_json = serde_json::to_string(&value[data_name]).ok()?; - let signature = serde_json::to_string(&value["signature"]).ok()?; - // We want the signature without leading/ending " - let signature = signature.replace('\"', ""); - Some((data_json, signature)) - } - - fn write_data_to_disk(filename: &str, contents: &[u8]) { - let mut file = std::fs::File::create(filename).unwrap(); - file.write_all(contents).unwrap(); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn separate_json_data_and_signature() { - // A bit more complex json to ensure the ordering stays the same - let json = br#"{"tcbInfo":{"id":"SGX","version":3,"issueDate":"2022-11-17T12:45:32Z"},"signature":"71746f2"}"#; - let (data, signature) = - SgxQlQveCollateral::separate_json_data_and_signature("tcbInfo", json).unwrap(); - assert_eq!(data, r#"{"id":"SGX","version":3,"issueDate":"2022-11-17T12:45:32Z"}"#); - assert_eq!(signature, "71746f2"); - - let json = br#"{"tcbInfo":{not_a_valid_json},"nosignature":"thesignature"}"#; - assert!(SgxQlQveCollateral::separate_json_data_and_signature("tcbInfo", json).is_none()); - - let json = br#"{"tcbInfo":{"id":"SGX"},"nosignature":"thesignature"}"#; - assert!(SgxQlQveCollateral::separate_json_data_and_signature("tcbInfo", json).is_none()); - - let json = br#"{"tcbInfo":{"id":"SGX"},"signature":""#; - assert!(SgxQlQveCollateral::separate_json_data_and_signature("tcbInfo", json).is_none()); - } -} diff --git a/tee-worker/identity/core-primitives/attestation-handler/src/error.rs b/tee-worker/identity/core-primitives/attestation-handler/src/error.rs deleted file mode 100644 index e681ce8c2a..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/src/error.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use sgx_types::sgx_status_t; -use std::boxed::Box; - -pub type Result = core::result::Result; - -/// Parentchain block importer error. -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("SGX error, status: {0}")] - Sgx(sgx_status_t), - #[error("{0}")] - IoError(#[from] std::io::Error), - #[error("Crypto error: {0}")] - Crypto(itp_sgx_crypto::Error), - #[error("Error specifying time")] - Time, - #[error(transparent)] - Other(#[from] Box), -} - -impl From for Error { - fn from(sgx_status: sgx_status_t) -> Self { - Self::Sgx(sgx_status) - } -} - -impl From for Error { - fn from(error: itp_sgx_crypto::error::Error) -> Self { - Self::Crypto(error) - } -} - -impl From for sgx_status_t { - /// return sgx_status for top level enclave functions - fn from(error: Error) -> sgx_status_t { - match error { - Error::Sgx(status) => status, - _ => { - log::error!("Returning error {:?} as sgx unexpected.", error); - sgx_status_t::SGX_ERROR_UNEXPECTED - }, - } - } -} diff --git a/tee-worker/identity/core-primitives/attestation-handler/src/lib.rs b/tee-worker/identity/core-primitives/attestation-handler/src/lib.rs deleted file mode 100644 index c6763b3d9a..0000000000 --- a/tee-worker/identity/core-primitives/attestation-handler/src/lib.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -#[macro_use] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use base64_sgx as base64; - pub use chrono_sgx as chrono; - pub use rustls_sgx as rustls; - pub use serde_json_sgx as serde_json; - pub use thiserror_sgx as thiserror; - pub use webpki_sgx as webpki; - pub use yasna_sgx as yasna; -} - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod attestation_handler; - -pub mod collateral; - -pub mod cert; - -pub mod error; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub use attestation_handler::{AttestationHandler, IntelAttestationHandler, DEV_HOSTNAME}; -pub use collateral::SgxQlQveCollateral; - -pub use error::{Error, Result}; - -#[derive(Clone, Eq, PartialEq, Debug)] -pub enum RemoteAttestationType { - Epid, - Dcap, -} diff --git a/tee-worker/identity/core-primitives/binary-merkle-tree/Cargo.toml b/tee-worker/identity/core-primitives/binary-merkle-tree/Cargo.toml deleted file mode 100644 index ab2acb0250..0000000000 --- a/tee-worker/identity/core-primitives/binary-merkle-tree/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "itp-binary-merkle-tree" -version = "0.8.0" -edition = "2021" - -[dependencies] -parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -binary-merkle-tree = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -std = [ - "parity-scale-codec/std", - "serde/std", - "binary-merkle-tree/std", -] diff --git a/tee-worker/identity/core-primitives/binary-merkle-tree/src/lib.rs b/tee-worker/identity/core-primitives/binary-merkle-tree/src/lib.rs deleted file mode 100644 index 9dc9ecd364..0000000000 --- a/tee-worker/identity/core-primitives/binary-merkle-tree/src/lib.rs +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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. - -*/ - -// Todo: I think we can upstream the codec change, then we can delete this crate. - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(not(feature = "std"))] -extern crate alloc; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - -use parity_scale_codec::{Decode, Encode}; -use serde::{Deserialize, Serialize}; - -// re-export the original one implementing all the merkle/logic. -pub use binary_merkle_tree::{merkle_proof, merkle_root, verify_proof, MerkleProof}; - -/// Custom Merkle proof that implements codec -/// The difference to the original one is that implements the scale-codec and that the fields contain u32 instead of usize. -#[derive(Debug, PartialEq, Eq, Decode, Encode, Deserialize, Serialize)] -pub struct MerkleProofWithCodec { - /// Root hash of generated merkle tree. - pub root: H, - /// Proof items (does not contain the leaf hash, nor the root obviously). - /// - /// This vec contains all inner node hashes necessary to reconstruct the root hash given the - /// leaf hash. - pub proof: Vec, - /// Number of leaves in the original tree. - /// - /// This is needed to detect a case where we have an odd number of leaves that "get promoted" - /// to upper layers. - pub number_of_leaves: u64, - /// Index of the leaf the proof is for (0-based). - pub leaf_index: u64, - /// Leaf content. - pub leaf: L, -} - -impl From> for MerkleProofWithCodec { - fn from(source: MerkleProof) -> Self { - Self { - root: source.root, - proof: source.proof, - // usize as u64 can't panic - number_of_leaves: source.number_of_leaves as u64, - leaf_index: source.leaf_index as u64, - leaf: source.leaf, - } - } -} diff --git a/tee-worker/identity/core-primitives/component-container/Cargo.toml b/tee-worker/identity/core-primitives/component-container/Cargo.toml deleted file mode 100644 index cb5d3b5541..0000000000 --- a/tee-worker/identity/core-primitives/component-container/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "itp-component-container" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - # sgx - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/identity/core-primitives/component-container/src/atomic_container.rs b/tee-worker/identity/core-primitives/component-container/src/atomic_container.rs deleted file mode 100644 index 3f52ab291a..0000000000 --- a/tee-worker/identity/core-primitives/component-container/src/atomic_container.rs +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Container for a generic item, held by an AtomicPtr. - -#[cfg(feature = "sgx")] -use std::sync::SgxMutex as Mutex; - -#[cfg(feature = "std")] -use std::sync::Mutex; - -use std::{ - default::Default, - sync::{ - atomic::{AtomicPtr, Ordering}, - Arc, - }, -}; - -/// Generic atomic container that holds an item in a container. -pub struct AtomicContainer { - atomic_ptr: AtomicPtr<()>, -} - -impl AtomicContainer { - pub const fn new() -> Self { - AtomicContainer { atomic_ptr: AtomicPtr::new(0 as *mut ()) } - } - - /// Store and item in the container. - pub fn store(&self, item: T) { - let pool_ptr = Arc::new(Mutex::::new(item)); - let ptr = Arc::into_raw(pool_ptr); - self.atomic_ptr.store(ptr as *mut (), Ordering::SeqCst); - } - - /// Load an item from the container, returning a mutex. - pub fn load(&self) -> Option<&Mutex> { - let ptr = self.atomic_ptr.load(Ordering::SeqCst) as *mut Mutex; - if ptr.is_null() { - None - } else { - Some(unsafe { &*ptr }) - } - } -} - -impl Default for AtomicContainer { - fn default() -> Self { - Self::new() - } -} - -#[cfg(test)] -pub mod tests { - - use super::*; - use std::{ - ops::Deref, - string::{String, ToString}, - vec::Vec, - }; - - #[derive(PartialEq, Eq, Clone, Debug)] - struct TestPayload { - name: String, - data: Vec, - } - - #[test] - pub fn store_and_load_works() { - let atomic_container = AtomicContainer::new(); - - let test_payload = TestPayload { - name: "Payload".to_string(), - data: Vec::from("lots_of_data_to_be_stored".as_bytes()), - }; - - atomic_container.store(test_payload.clone()); - - let retrieved_mutex = atomic_container.load::().unwrap().lock().unwrap(); - let retrieved_payload = retrieved_mutex.deref(); - - assert_eq!(&test_payload, retrieved_payload); - } -} diff --git a/tee-worker/identity/core-primitives/component-container/src/component_container.rs b/tee-worker/identity/core-primitives/component-container/src/component_container.rs deleted file mode 100644 index ec0a16d50e..0000000000 --- a/tee-worker/identity/core-primitives/component-container/src/component_container.rs +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Generic component containers. - -#[cfg(feature = "sgx")] -use std::sync::SgxMutex as Mutex; - -#[cfg(feature = "std")] -use std::sync::Mutex; - -use crate::{ - atomic_container::AtomicContainer, - error::{Error, Result}, -}; -use std::{ - format, - marker::PhantomData, - string::{String, ToString}, - sync::Arc, -}; - -/// Trait to initialize a generic component. -pub trait ComponentInitializer { - type ComponentType; - - fn initialize(&self, component: Arc); -} - -/// Trait to retrieve a generic component. -pub trait ComponentGetter { - type ComponentType; - - /// Try to get a specific component, returns `None` if component has not been initialized. - fn get(&self) -> Result>; -} - -/// Workaround to make `new()` a `const fn`. -/// Is required in order to have the `ComponentContainer` in a static variable. -struct Invariant(T); - -/// Component container implementation. Can be used in a global static context. -pub struct ComponentContainer { - container: AtomicContainer, - component_name: &'static str, - _phantom: PhantomData>, -} - -impl ComponentContainer { - /// Create a new container instance. - /// - /// Has to be `const` in order to be used in a `static` context. - pub const fn new(component_name: &'static str) -> Self { - ComponentContainer { - container: AtomicContainer::new(), - component_name, - _phantom: PhantomData, - } - } -} - -impl ComponentInitializer for ComponentContainer { - type ComponentType = Component; - - fn initialize(&self, component: Arc) { - self.container.store(component) - } -} - -impl ToString for ComponentContainer { - fn to_string(&self) -> String { - format!("{} component", self.component_name) - } -} - -impl ComponentGetter for ComponentContainer { - type ComponentType = Component; - - fn get(&self) -> Result> { - let component_mutex: &Mutex> = self - .container - .load() - .ok_or_else(|| Error::ComponentNotInitialized(self.to_string()))?; - Ok(component_mutex.lock().expect("Lock poisoning").clone()) - } -} diff --git a/tee-worker/identity/core-primitives/component-container/src/error.rs b/tee-worker/identity/core-primitives/component-container/src/error.rs deleted file mode 100644 index 9ca0ac0b20..0000000000 --- a/tee-worker/identity/core-primitives/component-container/src/error.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use std::{boxed::Box, string::String}; - -pub type Result = core::result::Result; - -/// extrinsics factory error -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Component is not initialized: {0}")] - ComponentNotInitialized(String), - #[error(transparent)] - Other(#[from] Box), -} diff --git a/tee-worker/identity/core-primitives/component-container/src/lib.rs b/tee-worker/identity/core-primitives/component-container/src/lib.rs deleted file mode 100644 index 9c684e4361..0000000000 --- a/tee-worker/identity/core-primitives/component-container/src/lib.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -mod atomic_container; -pub mod component_container; -pub mod error; - -pub use component_container::*; diff --git a/tee-worker/identity/core-primitives/enclave-api/Cargo.toml b/tee-worker/identity/core-primitives/enclave-api/Cargo.toml index 701590b2ae..9eab618dd0 100644 --- a/tee-worker/identity/core-primitives/enclave-api/Cargo.toml +++ b/tee-worker/identity/core-primitives/enclave-api/Cargo.toml @@ -1,33 +1,32 @@ [package] -name = "itp-enclave-api" +name = "id-itp-enclave-api" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -hex = "0.4" -log = "0.4" -serde_json = "1.0" -thiserror = "1.0.25" +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +log = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_urts = { optional = true, branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_crypto_helper = { workspace = true } +sgx_types = { workspace = true } +sgx_urts = { workspace = true, optional = true } -frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } -itc-parentchain = { path = "../../core/parentchain/parentchain-crate" } -itp-enclave-api-ffi = { path = "ffi" } -itp-settings = { path = "../settings" } -itp-stf-interface = { path = "../stf-interface" } -itp-storage = { path = "../storage" } -itp-types = { path = "../types" } +itp-enclave-api-ffi = { package = "id-itp-enclave-api-ffi", path = "ffi" } +itp-settings = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-stf-interface = { workspace = true } +itp-storage = { workspace = true } +itp-types = { workspace = true } -# litentry -pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } +pallet-teebag = { workspace = true } [features] default = [] diff --git a/tee-worker/identity/core-primitives/enclave-api/ffi/Cargo.toml b/tee-worker/identity/core-primitives/enclave-api/ffi/Cargo.toml index 1e101deae5..d719921b58 100644 --- a/tee-worker/identity/core-primitives/enclave-api/ffi/Cargo.toml +++ b/tee-worker/identity/core-primitives/enclave-api/ffi/Cargo.toml @@ -1,12 +1,10 @@ [package] -name = "itp-enclave-api-ffi" +name = "id-itp-enclave-api-ffi" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_types = { workspace = true } [features] # necessary to run cargo tests without any preliminaries diff --git a/tee-worker/identity/core-primitives/enclave-api/ffi/build.rs b/tee-worker/identity/core-primitives/enclave-api/ffi/build.rs index 766abb3eb4..35a9b8fe80 100644 --- a/tee-worker/identity/core-primitives/enclave-api/ffi/build.rs +++ b/tee-worker/identity/core-primitives/enclave-api/ffi/build.rs @@ -24,7 +24,7 @@ fn main() { let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string()); // NOTE: if the crate is a workspace member rustc-paths are relative from the root directory - println!("cargo:rustc-link-search=native=./lib"); + println!("cargo:rustc-link-search=native=./identity/lib"); println!("cargo:rustc-link-lib=static=Enclave_u"); println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); diff --git a/tee-worker/identity/core-primitives/enclave-api/src/enclave_base.rs b/tee-worker/identity/core-primitives/enclave-api/src/enclave_base.rs index 98ccb7c177..3287c7b967 100644 --- a/tee-worker/identity/core-primitives/enclave-api/src/enclave_base.rs +++ b/tee-worker/identity/core-primitives/enclave-api/src/enclave_base.rs @@ -19,9 +19,11 @@ use crate::EnclaveResult; use codec::Decode; use core::fmt::Debug; -use itc_parentchain::primitives::{ParentchainId, ParentchainInitParams}; use itp_stf_interface::ShardCreationInfo; -use itp_types::{parentchain::Header, ShardIdentifier}; +use itp_types::{ + parentchain::{Header, ParentchainId, ParentchainInitParams}, + ShardIdentifier, +}; use pallet_teebag::EnclaveFingerprint; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use sp_core::ed25519; @@ -91,13 +93,15 @@ mod impl_ffi { use codec::{Decode, Encode}; use core::fmt::Debug; use frame_support::ensure; - use itc_parentchain::primitives::{ParentchainId, ParentchainInitParams}; use itp_enclave_api_ffi as ffi; use itp_settings::worker::{ HEADER_MAX_SIZE, MR_ENCLAVE_SIZE, SHIELDING_KEY_SIZE, SIGNING_KEY_SIZE, }; use itp_stf_interface::ShardCreationInfo; - use itp_types::{parentchain::Header, ShardIdentifier}; + use itp_types::{ + parentchain::{Header, ParentchainId, ParentchainInitParams}, + ShardIdentifier, + }; use log::*; use pallet_teebag::EnclaveFingerprint; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; diff --git a/tee-worker/identity/core-primitives/enclave-metrics/Cargo.toml b/tee-worker/identity/core-primitives/enclave-metrics/Cargo.toml deleted file mode 100644 index 0b823cf090..0000000000 --- a/tee-worker/identity/core-primitives/enclave-metrics/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "itp-enclave-metrics" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# sgx -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] } -lc-stf-task-sender = { path = "../../litentry/core/stf-task/sender", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "litentry-primitives/std", - "lc-stf-task-sender/std", - -] -sgx = [ - "sgx_tstd", - "litentry-primitives/sgx", - "lc-stf-task-sender/sgx", -] diff --git a/tee-worker/identity/core-primitives/extrinsics-factory/Cargo.toml b/tee-worker/identity/core-primitives/extrinsics-factory/Cargo.toml deleted file mode 100644 index fcaa115701..0000000000 --- a/tee-worker/identity/core-primitives/extrinsics-factory/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "itp-extrinsics-factory" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# local dependencies -itp-node-api = { path = "../node-api", default-features = false } -itp-nonce-cache = { path = "../nonce-cache", default-features = false } -itp-types = { path = "../types", default-features = false } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "itp-node-api/std", - "itp-nonce-cache/std", - "itp-types/std", - "log/std", - "substrate-api-client/std", - "thiserror", -] -sgx = [ - "itp-node-api/sgx", - "itp-nonce-cache/sgx", - "sgx_tstd", - "thiserror_sgx", -] -mocks = [] diff --git a/tee-worker/identity/core-primitives/extrinsics-factory/src/error.rs b/tee-worker/identity/core-primitives/extrinsics-factory/src/error.rs deleted file mode 100644 index 4f052b9f94..0000000000 --- a/tee-worker/identity/core-primitives/extrinsics-factory/src/error.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use sgx_types::sgx_status_t; -use std::{boxed::Box, format}; - -pub type Result = core::result::Result; - -/// extrinsics factory error -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Nonce cache error: {0}")] - NonceCache(#[from] itp_nonce_cache::error::Error), - #[error("Node API error: {0:?}")] - NodeMetadataProvider(#[from] itp_node_api::metadata::provider::Error), - #[error("SGX error, status: {0}")] - Sgx(sgx_status_t), - #[error(transparent)] - Other(#[from] Box), -} - -impl From for Error { - fn from(sgx_status: sgx_status_t) -> Self { - Self::Sgx(sgx_status) - } -} - -impl From for Error { - fn from(e: codec::Error) -> Self { - Self::Other(format!("{:?}", e).into()) - } -} diff --git a/tee-worker/identity/core-primitives/hashing/src/lib.rs b/tee-worker/identity/core-primitives/hashing/src/lib.rs deleted file mode 100644 index 6e44afbcaa..0000000000 --- a/tee-worker/identity/core-primitives/hashing/src/lib.rs +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ -//! Hashing traits and utilities. - -#![cfg_attr(not(feature = "std"), no_std)] - -use sp_core::H256; - -#[cfg(feature = "std")] -pub mod std_hash; - -/// Trait to compute a hash of self. -pub trait Hash { - fn hash(&self) -> Output; -} - -// Cannot use the implementation below unfortunately, because our externalities -// have their own hash implementation which ignores the state diff. -// /// Implement Hash for any types that implement encode. -// /// -// /// -// impl Hash for T { -// fn hash(&self) -> H256 { -// blake2_256(&self.encode()).into() -// } -// } - -pub fn hash_from_slice(hash_slize: &[u8]) -> H256 { - let mut g = [0; 32]; - g.copy_from_slice(hash_slize); - H256::from(&mut g) -} diff --git a/tee-worker/identity/core-primitives/hashing/src/std_hash.rs b/tee-worker/identity/core-primitives/hashing/src/std_hash.rs deleted file mode 100644 index 2a6524a800..0000000000 --- a/tee-worker/identity/core-primitives/hashing/src/std_hash.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::Hash; -use std::{ - collections::hash_map::DefaultHasher, - hash::{Hash as StdHash, Hasher}, -}; - -/// Implement Hash for all types implementing core::hash::Hash. -impl Hash for T { - fn hash(&self) -> u64 { - let mut hasher = DefaultHasher::new(); - self.hash(&mut hasher); - hasher.finish() - } -} diff --git a/tee-worker/identity/core-primitives/import-queue/Cargo.toml b/tee-worker/identity/core-primitives/import-queue/Cargo.toml deleted file mode 100644 index 2d358d8102..0000000000 --- a/tee-worker/identity/core-primitives/import-queue/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "itp-import-queue" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# crates.io std-only compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries - -[features] -default = ["std"] -std = [ - # no-std compatible libraries - # std compatible external libraries - "thiserror", -] -sgx = [ - # sgx - "sgx_tstd", - # sgx enabled external libraries - "thiserror_sgx", -] diff --git a/tee-worker/identity/core-primitives/import-queue/src/error.rs b/tee-worker/identity/core-primitives/import-queue/src/error.rs deleted file mode 100644 index c1492cf550..0000000000 --- a/tee-worker/identity/core-primitives/import-queue/src/error.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use sgx_types::sgx_status_t; -use std::boxed::Box; - -pub type Result = core::result::Result; - -/// Parentchain block importer error. -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("SGX error, status: {0}")] - Sgx(sgx_status_t), - #[error("Queue lock is poisoned")] - PoisonedLock, - #[error(transparent)] - Other(#[from] Box), -} - -impl From for Error { - fn from(sgx_status: sgx_status_t) -> Self { - Self::Sgx(sgx_status) - } -} diff --git a/tee-worker/identity/core-primitives/import-queue/src/import_queue.rs b/tee-worker/identity/core-primitives/import-queue/src/import_queue.rs deleted file mode 100644 index 2555d3b5a3..0000000000 --- a/tee-worker/identity/core-primitives/import-queue/src/import_queue.rs +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Import queue implementation - -#[cfg(feature = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - PeekQueue, PopFromQueue, PushToQueue, -}; -use std::{collections::VecDeque, vec::Vec}; - -/// Any import queue. -/// -/// Uses RwLock internally to guard against concurrent access and ensure all operations are atomic. -pub struct ImportQueue { - queue: RwLock>, -} - -impl ImportQueue { - pub fn is_empty(&self) -> Result { - let queue_lock = self.queue.read().map_err(|_| Error::PoisonedLock)?; - Ok(queue_lock.is_empty()) - } -} - -impl Default for ImportQueue { - fn default() -> Self { - ImportQueue { queue: Default::default() } - } -} - -impl PushToQueue for ImportQueue { - fn push_multiple(&self, items: Vec) -> Result<()> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - queue_lock.extend(items); - Ok(()) - } - - fn push_single(&self, item: Item) -> Result<()> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - queue_lock.push_back(item); - Ok(()) - } -} - -impl PopFromQueue for ImportQueue { - type ItemType = Item; - - fn pop_all_but_last(&self) -> Result> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - let queue_length = queue_lock.len(); - if queue_length < 2 { - return Ok(Vec::::default()) - } - Ok(queue_lock.drain(..queue_length - 1).collect::>()) - } - - fn pop_all(&self) -> Result> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - Ok(queue_lock.drain(..).collect::>()) - } - - fn pop_until(&self, predicate: Predicate) -> Result> - where - Predicate: FnMut(&Self::ItemType) -> bool, - { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - match queue_lock.iter().position(predicate) { - None => Ok(Vec::new()), - Some(p) => Ok(queue_lock.drain(..p + 1).collect::>()), - } - } - - fn pop_front(&self) -> Result> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - Ok(queue_lock.pop_front()) - } - - fn pop_from_front_until(&self, amount: usize) -> Result> { - let mut queue_lock = self.queue.write().map_err(|_| Error::PoisonedLock)?; - if amount > queue_lock.len() { - return Err(Error::Other( - "Cannot Pop more items from the queue than are available".into(), - )) - } - Ok(queue_lock.drain(..amount).collect::>()) - } -} - -impl PeekQueue for ImportQueue -where - Item: Clone, -{ - type ItemType = Item; - - fn peek_find(&self, predicate: Predicate) -> Result> - where - Predicate: Fn(&Self::ItemType) -> bool, - { - let queue_lock = self.queue.read().map_err(|_| Error::PoisonedLock)?; - let maybe_item = queue_lock.iter().find(|&b| predicate(b)); - Ok(maybe_item.cloned()) - } - - fn peek_last(&self) -> Result> { - let queue_lock = self.queue.read().map_err(|_| Error::PoisonedLock)?; - Ok(queue_lock.back().cloned()) - } - - fn peek_queue_size(&self) -> Result { - let queue_lock = self.queue.read().map_err(|_| Error::PoisonedLock)?; - Ok(queue_lock.len()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use core::assert_matches::assert_matches; - - type TestBlock = u32; - - #[test] - fn default_queue_is_empty() { - let queue = ImportQueue::::default(); - assert!(queue.is_empty().unwrap()); - } - - #[test] - fn pop_all_on_default_returns_empty_vec() { - let queue = ImportQueue::::default(); - assert!(queue.pop_all().unwrap().is_empty()); - } - - #[test] - fn after_inserting_queue_is_not_empty() { - let queue = ImportQueue::::default(); - queue.push_single(TestBlock::default()).unwrap(); - assert!(!queue.is_empty().unwrap()); - } - - #[test] - fn pop_all_after_inserting_leaves_empty_queue() { - let queue = ImportQueue::::default(); - queue - .push_multiple(vec![TestBlock::default(), TestBlock::default(), TestBlock::default()]) - .unwrap(); - - let all_popped = queue.pop_all().unwrap(); - assert_eq!(3, all_popped.len()); - assert!(queue.is_empty().unwrap()); - } - - #[test] - fn pop_all_except_last_on_default_returns_empty_vec() { - let queue = ImportQueue::::default(); - assert!(queue.pop_all_but_last().unwrap().is_empty()); - } - - #[test] - fn pop_all_except_last_with_single_element_returns_empty_vec() { - let queue = ImportQueue::::default(); - queue.push_single(TestBlock::default()).unwrap(); - assert!(queue.pop_all_but_last().unwrap().is_empty()); - } - - #[test] - fn pop_all_except_last_with_multiple_elements_returns_all_but_last_inserted() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 3, 5, 7]).unwrap(); - assert_eq!(3, queue.pop_all_but_last().unwrap().len()); - assert!(!queue.is_empty().unwrap()); - assert_eq!(7, queue.pop_all().unwrap()[0]); - } - - #[test] - fn pop_until_returns_empty_vec_if_nothing_matches() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 3, 5, 7]).unwrap(); - - let popped_elements = queue.pop_until(|i| i > &10u32).unwrap(); - assert!(popped_elements.is_empty()); - } - - #[test] - fn pop_until_returns_elements_until_and_including_match() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 2, 3, 10]).unwrap(); - - assert_eq!(queue.pop_until(|i| i == &3).unwrap(), vec![1, 2, 3]); - } - - #[test] - fn pop_until_returns_all_elements_if_last_matches() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 2, 3, 10]).unwrap(); - - assert_eq!(queue.pop_until(|i| i == &10).unwrap(), vec![1, 2, 3, 10]); - } - - #[test] - fn pop_until_returns_first_element_if_it_matches() { - let queue = ImportQueue::::default(); - queue.push_single(4).unwrap(); - assert_eq!(queue.pop_until(|i| i == &4).unwrap(), vec![4]) - } - - #[test] - fn pop_front_returns_none_if_queue_is_empty() { - let queue = ImportQueue::::default(); - assert_matches!(queue.pop_front().unwrap(), None); - } - - #[test] - fn pop_front_works() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 2, 3, 5]).unwrap(); - assert_eq!(queue.pop_front().unwrap(), Some(1)); - assert_eq!(queue.pop_front().unwrap(), Some(2)); - assert_eq!(queue.pop_front().unwrap(), Some(3)); - assert_eq!(queue.pop_front().unwrap(), Some(5)); - assert_eq!(queue.pop_front().unwrap(), None); - } - - #[test] - fn peek_find_works() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 2, 3, 5]).unwrap(); - - assert_eq!(None, queue.peek_find(|i| i == &4).unwrap()); - assert!(queue.peek_find(|i| i == &1).unwrap().is_some()); - assert!(queue.peek_find(|i| i == &5).unwrap().is_some()); - } - - #[test] - fn peek_find_on_empty_queue_returns_none() { - let queue = ImportQueue::::default(); - assert_eq!(None, queue.peek_find(|i| i == &1).unwrap()); - } - - #[test] - fn peek_last_works() { - let queue = ImportQueue::::default(); - queue.push_multiple(vec![1, 2, 3, 5, 6, 9, 10]).unwrap(); - assert_eq!(queue.peek_last().unwrap(), Some(10)); - } - - #[test] - fn peek_last_on_empty_queue_returns_none() { - let queue = ImportQueue::::default(); - assert_eq!(None, queue.peek_last().unwrap()); - } -} diff --git a/tee-worker/identity/core-primitives/import-queue/src/lib.rs b/tee-worker/identity/core-primitives/import-queue/src/lib.rs deleted file mode 100644 index d223317f78..0000000000 --- a/tee-worker/identity/core-primitives/import-queue/src/lib.rs +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ -//! Queueing of item imports. - -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(test, feature(assert_matches))] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -pub mod error; -pub mod import_queue; - -pub use import_queue::*; - -use error::Result; -use std::vec::Vec; - -/// Trait to push items such as blocks to an import queue. -pub trait PushToQueue { - /// Push multiple items to the queue, ordering from the Vec is preserved. - fn push_multiple(&self, item: Vec) -> Result<()>; - - /// Push a single item to the queue. - fn push_single(&self, item: Item) -> Result<()>; -} - -/// Trait to pop items from the import queue. -pub trait PopFromQueue { - type ItemType; - - /// Pop (i.e. removes and returns) all but the last item from the import queue. - fn pop_all_but_last(&self) -> Result>; - - /// Pop (i.e. removes and returns) all items from the import queue. - fn pop_all(&self) -> Result>; - - /// Pop (front) until specified item is found. If no item matches, empty Vec is returned. - fn pop_until(&self, predicate: Predicate) -> Result> - where - Predicate: Fn(&Self::ItemType) -> bool; - - /// Pop (front) queue. Returns None if queue is empty. - fn pop_front(&self) -> Result>; - - /// Pop (front) queue until a specific amount of pops has been reached - fn pop_from_front_until(&self, amount: usize) -> Result>; -} - -/// Trait to peek items in the import queue without altering the queue. -pub trait PeekQueue { - type ItemType: Clone; - - /// Search the queue with a given predicate and return a reference to the first element that matches. - /// Returns None if nothing matches. - fn peek_find(&self, predicate: Predicate) -> Result> - where - Predicate: Fn(&Self::ItemType) -> bool; - - /// Peeks the last element in the queue (aka the newest one, last to be popped). - /// Returns None if queue is empty. - fn peek_last(&self) -> Result>; - - /// Peek the queue size (i.e. number of elements the queue contains). - fn peek_queue_size(&self) -> Result; -} diff --git a/tee-worker/identity/core-primitives/networking-utils/Cargo.toml b/tee-worker/identity/core-primitives/networking-utils/Cargo.toml deleted file mode 100644 index 41032ef41d..0000000000 --- a/tee-worker/identity/core-primitives/networking-utils/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "itp-networking-utils" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - -] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/identity/core-primitives/networking-utils/src/lib.rs b/tee-worker/identity/core-primitives/networking-utils/src/lib.rs deleted file mode 100644 index 46b8ab91d3..0000000000 --- a/tee-worker/identity/core-primitives/networking-utils/src/lib.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -pub mod ports; diff --git a/tee-worker/identity/core-primitives/networking-utils/src/ports.rs b/tee-worker/identity/core-primitives/networking-utils/src/ports.rs deleted file mode 100644 index 4b8a523b27..0000000000 --- a/tee-worker/identity/core-primitives/networking-utils/src/ports.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{net::TcpListener, ops::Range}; - -/// Gets the first available port in a range. -/// Returns None if no port in range is available. -/// -pub fn get_available_port_in_range(mut port_range: Range) -> Option { - port_range.find(|port| port_is_available(*port)) -} - -fn port_is_available(port: u16) -> bool { - TcpListener::bind(("127.0.0.1", port)).is_ok() -} - -#[cfg(test)] -mod tests { - use super::*; - use std::mem::drop; - - #[test] - fn port_is_not_available_when_bound() { - let available_port = get_available_port_in_range(12000..13000).unwrap(); - - let tcp_listener = TcpListener::bind(("127.0.0.1", available_port)).unwrap(); - - assert!(!port_is_available(available_port)); - - drop(tcp_listener); - - assert!(port_is_available(available_port)); - } -} diff --git a/tee-worker/identity/core-primitives/node-api/api-client-extensions/Cargo.toml b/tee-worker/identity/core-primitives/node-api/api-client-extensions/Cargo.toml deleted file mode 100644 index 45f0141dd2..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-extensions/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "itp-api-client-extensions" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] - -# substrate -sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# scs -# `default-features = false` to remove the jsonrpsee dependency. -substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# local deps -itp-api-client-types = { path = "../api-client-types" } -itp-types = { path = "../../types" } - -[features] -# used for unit testing only! -mocks = [] diff --git a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/account.rs b/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/account.rs deleted file mode 100644 index 8834f942bb..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/account.rs +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::ApiResult; -use itp_api_client_types::{ - traits::GetAccountInformation, Api, Config, ParentchainRuntimeConfig, Request, -}; - -/// ApiClient extension that contains some convenience methods around accounts. -// Todo: make generic over `Config` type instead? -pub trait AccountApi { - type AccountId; - type Index; - type Balance; - - fn get_nonce_of(&self, who: &Self::AccountId) -> ApiResult; - fn get_free_balance(&self, who: &Self::AccountId) -> ApiResult; - fn get_account_next_index(&self, who: &Self::AccountId) -> ApiResult; -} - -impl AccountApi for Api -where - Client: Request, -{ - type AccountId = ::AccountId; - type Index = ::Index; - type Balance = ::Balance; - - fn get_nonce_of(&self, who: &Self::AccountId) -> ApiResult { - Ok(self.get_account_info(who)?.map(|info| info.nonce).unwrap_or_default()) - } - - fn get_free_balance(&self, who: &Self::AccountId) -> ApiResult { - Ok(self.get_account_data(who)?.map(|data| data.free).unwrap_or_default()) - } - - fn get_account_next_index(&self, who: &Self::AccountId) -> ApiResult { - self.get_system_account_next_index(who.clone()) - } -} diff --git a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/chain.rs b/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/chain.rs deleted file mode 100644 index 0333c41f66..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/chain.rs +++ /dev/null @@ -1,156 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ApiClientError, ApiResult}; -use itp_api_client_types::{ - storage_key, - traits::{GetChainInfo, GetStorage}, - Api, Config, Request, StorageKey, -}; -use itp_types::parentchain::{BlockNumber, StorageProof}; -use sp_consensus_grandpa::{AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; -use sp_runtime::generic::SignedBlock as GenericSignedBlock; - -type RawEvents = Vec; - -/// ApiClient extension that simplifies chain data access. -pub trait ChainApi { - type Hash; - type Block; - type Header; - type BlockNumber; - - fn last_finalized_block(&self) -> ApiResult>>; - fn signed_block( - &self, - hash: Option, - ) -> ApiResult>>; - fn get_genesis_hash(&self) -> ApiResult; - fn header(&self, header_hash: Option) -> ApiResult>; - /// Fetch blocks from parentchain with blocknumber from until to, including both boundaries. - /// Returns a vector with one element if from equals to. - /// Returns an empty vector if from is greater than to. - fn get_blocks( - &self, - from: Self::BlockNumber, - to: Self::BlockNumber, - ) -> ApiResult>>; - fn get_block_by_number( - &self, - block: Self::BlockNumber, - ) -> ApiResult>>; - fn is_grandpa_available(&self) -> ApiResult; - fn grandpa_authorities(&self, hash: Option) -> ApiResult; - fn grandpa_authorities_proof(&self, hash: Option) -> ApiResult; - fn get_events_value_proof(&self, block_hash: Option) -> ApiResult; - fn get_events_for_block(&self, block_hash: Option) -> ApiResult; -} - -impl ChainApi for Api -where - RuntimeConfig: Config, - Client: Request, -{ - type Hash = RuntimeConfig::Hash; - type Header = RuntimeConfig::Header; - type Block = RuntimeConfig::Block; - type BlockNumber = RuntimeConfig::BlockNumber; - - fn last_finalized_block(&self) -> ApiResult>> { - self.get_finalized_head()? - .map_or_else(|| Ok(None), |hash| self.signed_block(Some(hash))) - } - - fn signed_block( - &self, - hash: Option, - ) -> ApiResult>> { - Ok(self.get_signed_block(hash)?.map(|block| block.into())) - } - - fn get_genesis_hash(&self) -> ApiResult { - self.get_block_hash(Some(0u32))?.ok_or(ApiClientError::BlockHashNotFound) - } - - fn header(&self, header_hash: Option) -> ApiResult> { - self.get_header(header_hash) - } - - fn get_blocks( - &self, - from: Self::BlockNumber, - to: Self::BlockNumber, - ) -> ApiResult>> { - let mut blocks = Vec::>::new(); - - for n in from..=to { - if let Some(block) = self.get_signed_block_by_num(Some(n))? { - blocks.push(block.into()); - } - } - Ok(blocks) - } - - fn get_block_by_number( - &self, - block_number: Self::BlockNumber, - ) -> ApiResult>> { - match self.get_signed_block_by_num(Some(block_number))? { - Some(block) => Ok(Some(block.into())), - None => Ok(None), - } - } - - fn is_grandpa_available(&self) -> ApiResult { - let genesis_hash = Some(self.get_genesis_hash().expect("Failed to get genesis hash")); - Ok(self - .get_storage_by_key(StorageKey(GRANDPA_AUTHORITIES_KEY.to_vec()), genesis_hash)? - .map(|v: VersionedAuthorityList| v.into()) - .map(|v: AuthorityList| !v.is_empty()) - .unwrap_or(false)) - } - - fn grandpa_authorities(&self, at_block: Option) -> ApiResult { - Ok(self - .get_storage_by_key(StorageKey(GRANDPA_AUTHORITIES_KEY.to_vec()), at_block)? - .map(|g: VersionedAuthorityList| g.into()) - .unwrap_or_default()) - } - - fn grandpa_authorities_proof(&self, at_block: Option) -> ApiResult { - Ok(self - .get_storage_proof_by_keys( - vec![StorageKey(GRANDPA_AUTHORITIES_KEY.to_vec())], - at_block, - )? - .map(|read_proof| read_proof.proof.into_iter().map(|bytes| bytes.0).collect()) - .unwrap_or_default()) - } - - fn get_events_value_proof(&self, block_hash: Option) -> ApiResult { - let key = storage_key("System", "Events"); - Ok(self - .get_storage_proof_by_keys(Vec::from([key]), block_hash)? - .map(|read_proof| read_proof.proof.into_iter().map(|bytes| bytes.0).collect()) - .unwrap_or_default()) - } - - fn get_events_for_block(&self, block_hash: Option) -> ApiResult { - let key = storage_key("System", "Events"); - Ok(self.get_opaque_storage_by_key(key, block_hash)?.unwrap_or_default()) - } -} diff --git a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/lib.rs b/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/lib.rs deleted file mode 100644 index 668cefd2ba..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/lib.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Some substrate-api-client extension traits. - -pub use substrate_api_client::{api::Error as ApiClientError, rpc::TungsteniteRpcClient, Api}; - -pub mod account; -pub mod chain; -pub mod pallet_teebag; - -pub use account::*; -pub use chain::*; -pub use pallet_teebag::*; - -pub type ApiResult = Result; diff --git a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs b/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs deleted file mode 100644 index e243091ca5..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-extensions/src/pallet_teebag.rs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2020-2024 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 crate::ApiResult; -use itp_api_client_types::{traits::GetStorage, Api, Config, Request}; -use itp_types::{AccountId, Enclave, ShardIdentifier, WorkerType}; - -pub const TEEBAG: &str = "Teebag"; - -/// ApiClient extension that enables communication with the `teebag` pallet. -pub trait PalletTeebagApi { - type Hash; - - fn enclave( - &self, - account: &AccountId, - at_block: Option, - ) -> ApiResult>; - fn enclave_count( - &self, - worker_type: WorkerType, - at_block: Option, - ) -> ApiResult; - fn primary_enclave_identifier_for_shard( - &self, - worker_type: WorkerType, - shard: &ShardIdentifier, - at_block: Option, - ) -> ApiResult>; - fn primary_enclave_for_shard( - &self, - worker_type: WorkerType, - shard: &ShardIdentifier, - at_block: Option, - ) -> ApiResult>; - fn all_enclaves( - &self, - worker_type: WorkerType, - at_block: Option, - ) -> ApiResult>; -} - -impl PalletTeebagApi for Api -where - RuntimeConfig: Config, - Client: Request, -{ - type Hash = RuntimeConfig::Hash; - - fn enclave( - &self, - account: &AccountId, - at_block: Option, - ) -> ApiResult> { - self.get_storage_map(TEEBAG, "EnclaveRegistry", account, at_block) - } - - fn enclave_count( - &self, - worker_type: WorkerType, - at_block: Option, - ) -> ApiResult { - // Vec<> and BoundedVec<> have the same encoding, thus they are used interchangeably - let identifiers: Vec = self - .get_storage_map(TEEBAG, "EnclaveIdentifier", worker_type, at_block)? - .unwrap_or_default(); - Ok(identifiers.len() as u64) - } - - // please note we don't use dedicated on-chain storage for this (like the upstream `WorkerForShard`) - // so this API will always return the "first" registered and qualified enclave. - // Wheter it meets our needs needs to be further evaluated - fn primary_enclave_identifier_for_shard( - &self, - worker_type: WorkerType, - shard: &ShardIdentifier, - at_block: Option, - ) -> ApiResult> { - let identifiers: Vec = self - .get_storage_map(TEEBAG, "EnclaveIdentifier", worker_type, at_block)? - .unwrap_or_default(); - let mut maybe_account: Option = None; - for account in identifiers { - match self.enclave(&account, at_block)? { - Some(e) => - if e.mrenclave == shard.as_ref() { - maybe_account = Some(account.clone()); - break - }, - None => continue, - } - } - Ok(maybe_account) - } - - fn primary_enclave_for_shard( - &self, - worker_type: WorkerType, - shard: &ShardIdentifier, - at_block: Option, - ) -> ApiResult> { - self.primary_enclave_identifier_for_shard(worker_type, shard, at_block)? - .map_or_else(|| Ok(None), |account| self.enclave(&account, at_block)) - } - - fn all_enclaves( - &self, - worker_type: WorkerType, - at_block: Option, - ) -> ApiResult> { - let identifiers: Vec = self - .get_storage_map(TEEBAG, "EnclaveIdentifier", worker_type, at_block)? - .unwrap_or_default(); - - let enclaves = identifiers - .into_iter() - .filter_map(|account| self.enclave(&account, at_block).ok()?) - .collect(); - Ok(enclaves) - } -} diff --git a/tee-worker/identity/core-primitives/node-api/api-client-types/src/lib.rs b/tee-worker/identity/core-primitives/node-api/api-client-types/src/lib.rs deleted file mode 100644 index b82b0c376b..0000000000 --- a/tee-worker/identity/core-primitives/node-api/api-client-types/src/lib.rs +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Contains semi-generic type definitions to talk to the node without depending on an implementation of Runtime. -//! -//! You need to update this if you have a signed extension in your node that -//! is different from the integritee-node, e.g., if you use the `pallet_asset_tx_payment`. - -#![cfg_attr(not(feature = "std"), no_std)] - -pub use itp_types::parentchain::{ - AccountData, AccountId, AccountInfo, Address, Balance, Hash, Index, Signature as PairSignature, -}; -pub use substrate_api_client::{ - ac_node_api::{ - metadata::{InvalidMetadataError, Metadata, MetadataError}, - EventDetails, Events, StaticEvent, - }, - ac_primitives::{ - config::{AssetRuntimeConfig, Config, DefaultRuntimeConfig}, - extrinsics::{ - AssetTip, CallIndex, ExtrinsicParams, GenericAdditionalParams, GenericAdditionalSigned, - GenericExtrinsicParams, GenericSignedExtra, PlainTip, UncheckedExtrinsicV4, - }, - serde_impls::StorageKey, - signer::{SignExtrinsic, StaticExtrinsicSigner}, - }, - rpc::Request, - storage_key, Api, -}; - -// traits from the api-client -pub mod traits { - pub use substrate_api_client::{GetAccountInformation, GetChainInfo, GetStorage}; -} - -pub type ParentchainPlainTip = PlainTip; -pub type ParentchainAssetTip = AssetTip; - -/// Configuration for the ExtrinsicParams. -/// -/// Valid for the default integritee node -pub type ParentchainExtrinsicParams = - GenericExtrinsicParams; -pub type ParentchainAdditionalParams = GenericAdditionalParams; -pub use DefaultRuntimeConfig as ParentchainRuntimeConfig; - -// Pay in asset fees. -// -// This needs to be used if the node uses the `pallet_asset_tx_payment`. -//pub type ParentchainExtrinsicParams = GenericExtrinsicParams; -// pub type ParentchainAdditionalParams = GenericAdditionalParams; - -pub type ParentchainUncheckedExtrinsic = - UncheckedExtrinsicV4; -pub type ParentchainSignedExtra = GenericSignedExtra; -pub type ParentchainSignature = Signature; - -/// Signature type of the [UncheckedExtrinsicV4]. -pub type Signature = Option<(Address, PairSignature, SignedExtra)>; - -#[cfg(feature = "std")] -pub use api::*; - -#[cfg(feature = "std")] -mod api { - use super::ParentchainRuntimeConfig; - use substrate_api_client::Api; - - pub use substrate_api_client::{ - api::Error as ApiClientError, - rpc::{tungstenite_client::TungsteniteRpcClient, Error as RpcClientError}, - }; - - pub type ParentchainApi = Api; -} diff --git a/tee-worker/identity/core-primitives/node-api/factory/Cargo.toml b/tee-worker/identity/core-primitives/node-api/factory/Cargo.toml deleted file mode 100644 index edd4a821cb..0000000000 --- a/tee-worker/identity/core-primitives/node-api/factory/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "itp-node-api-factory" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -thiserror = { version = "1.0" } - -# substrate -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local -itp-api-client-types = { path = "../api-client-types" } diff --git a/tee-worker/identity/core-primitives/node-api/factory/src/lib.rs b/tee-worker/identity/core-primitives/node-api/factory/src/lib.rs deleted file mode 100644 index 2afea5f423..0000000000 --- a/tee-worker/identity/core-primitives/node-api/factory/src/lib.rs +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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 itp_api_client_types::{ParentchainApi, TungsteniteRpcClient}; -use sp_core::sr25519; - -/// Trait to create a node API, based on a node URL and signer. -pub trait CreateNodeApi: Send + Sync + 'static { - fn create_api(&self) -> Result; -} - -/// Node API factory error. -#[derive(Debug, thiserror::Error)] -pub enum NodeApiFactoryError { - #[error("Could not connect to node with rpc client")] - FailedToCreateRpcClient(itp_api_client_types::RpcClientError), - #[error("Failed to create a node API")] - FailedToCreateNodeApi(itp_api_client_types::ApiClientError), - #[error(transparent)] - Other(#[from] Box), -} - -impl From for NodeApiFactoryError { - fn from(error: itp_api_client_types::RpcClientError) -> Self { - NodeApiFactoryError::FailedToCreateRpcClient(error) - } -} - -impl From for NodeApiFactoryError { - fn from(error: itp_api_client_types::ApiClientError) -> Self { - NodeApiFactoryError::FailedToCreateNodeApi(error) - } -} - -pub type Result = std::result::Result; - -/// Node API factory implementation. -pub struct NodeApiFactory { - node_url: String, - signer: sr25519::Pair, -} - -impl NodeApiFactory { - pub fn new(url: String, signer: sr25519::Pair) -> Self { - NodeApiFactory { node_url: url, signer } - } -} - -impl CreateNodeApi for NodeApiFactory { - fn create_api(&self) -> Result { - let rpc_client = TungsteniteRpcClient::new(self.node_url.as_str(), 5) - .map_err(NodeApiFactoryError::FailedToCreateRpcClient)?; - let mut api = - ParentchainApi::new(rpc_client).map_err(NodeApiFactoryError::FailedToCreateNodeApi)?; - api.set_signer(self.signer.clone().into()); - Ok(api) - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata-provider/Cargo.toml b/tee-worker/identity/core-primitives/node-api/metadata-provider/Cargo.toml deleted file mode 100644 index 93ae23fcaa..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata-provider/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "itp-node-api-metadata-provider" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io - -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# sgx enabled external libraries -thiserror_sgx = { optional = true, package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# local dependencies -itp-node-api-metadata = { default-features = false, path = "../metadata" } -itp-stf-primitives = { default-features = false, path = "../../stf-primitives" } - -[features] -default = ["std"] -std = [ - "thiserror", - "itp-stf-primitives/std", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] -# used for unit testing only! -mocks = [] diff --git a/tee-worker/identity/core-primitives/node-api/metadata-provider/src/error.rs b/tee-worker/identity/core-primitives/node-api/metadata-provider/src/error.rs deleted file mode 100644 index fc45ff5f92..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata-provider/src/error.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -extern crate thiserror_sgx as thiserror; - -use itp_stf_primitives::error::StfError; - -#[derive(Debug, PartialEq, Eq, thiserror::Error)] -pub enum Error { - /// Metadata has not been set - #[error("Metadata has no been set")] - MetadataNotSet, - /// Node metadata error - #[error("Metadata Error: {0:?}")] - MetadataError(itp_node_api_metadata::error::Error), -} - -pub type Result = core::result::Result; - -impl From for Error { - fn from(e: itp_node_api_metadata::error::Error) -> Self { - Self::MetadataError(e) - } -} - -impl From for StfError { - fn from(_e: Error) -> Self { - StfError::InvalidMetadata - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata-provider/src/lib.rs b/tee-worker/identity/core-primitives/node-api/metadata-provider/src/lib.rs deleted file mode 100644 index 9d2f16d54d..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata-provider/src/lib.rs +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Minimalistic crate for global metadata access withing the enclave. - -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(test, feature(assert_matches))] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(feature = "sgx")] -extern crate sgx_tstd as std; - -#[cfg(feature = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -pub use crate::error::Error; - -use crate::error::Result; -use std::ops::Deref; - -pub mod error; - -/// Trait to get access to the node API metadata. -pub trait AccessNodeMetadata { - type MetadataType; - - fn get_from_metadata(&self, getter_function: F) -> Result - where - F: FnOnce(&Self::MetadataType) -> R; -} - -/// Repository to manage the node metadata. -/// -/// Provides simple means to set the metadata and read from it, guarded by a lock. -#[derive(Default)] -pub struct NodeMetadataRepository { - metadata_lock: RwLock>, -} - -impl NodeMetadataRepository { - pub fn new(metadata: NodeMetadata) -> Self { - NodeMetadataRepository { metadata_lock: RwLock::new(Some(metadata)) } - } - - pub fn set_metadata(&self, metadata: NodeMetadata) { - let mut metadata_lock = self.metadata_lock.write().expect("Lock poisoning"); - *metadata_lock = Some(metadata) - } -} - -impl AccessNodeMetadata for NodeMetadataRepository -where - NodeMetadata:, -{ - type MetadataType = NodeMetadata; - - fn get_from_metadata(&self, getter_function: F) -> Result - where - F: FnOnce(&Self::MetadataType) -> R, - { - match self.metadata_lock.read().expect("Lock poisoning").deref() { - Some(metadata) => Ok(getter_function(metadata)), - None => Err(Error::MetadataNotSet), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::assert_matches::assert_matches; - - #[derive(Default)] - struct NodeMetadataMock; - - impl NodeMetadataMock { - fn get_one(&self) -> u32 { - 1 - } - } - #[test] - fn get_from_meta_data_returns_error_if_not_set() { - let repo = NodeMetadataRepository::::default(); - - assert_matches!(repo.get_from_metadata(|m| m.get_one()), Err(Error::MetadataNotSet)); - } - - #[test] - fn get_from_metadata_works() { - let repo = NodeMetadataRepository::::default(); - repo.set_metadata(NodeMetadataMock); - - assert_eq!(1, repo.get_from_metadata(|m| m.get_one()).unwrap()); - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/Cargo.toml b/tee-worker/identity/core-primitives/node-api/metadata/Cargo.toml deleted file mode 100644 index 0592a6a09f..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "itp-node-api-metadata" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } - -# local -itp-api-client-types = { default-features = false, path = "../api-client-types" } -itp-stf-primitives = { default-features = false, path = "../../stf-primitives" } - -# substrate -sp-core = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.42" } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-api-client-types/std", - "sp-core/std", - "sp-version/std", - "itp-stf-primitives/std", -] - -# used for unit testing only! -mocks = [] diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/error.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/error.rs deleted file mode 100644 index c0bcf39355..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/error.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 derive_more::From; -use itp_stf_primitives::error::StfError; - -#[derive(Debug, PartialEq, Eq, From)] -pub enum Error { - /// Metadata has not been set - MetadataNotSet, - /// Api-client metadata error - NodeMetadata(itp_api_client_types::MetadataError), - // litentry - /// Invalid Metadata - InvalidMetadata, -} - -pub type Result = core::result::Result; - -impl From for StfError { - fn from(_e: Error) -> Self { - StfError::InvalidMetadata - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_balances.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_balances.rs deleted file mode 100644 index 9ae88dd742..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_balances.rs +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, NodeMetadata}; - -/// Pallet name: -const BALANCES: &str = "Balances"; - -pub trait BalancesCallIndexes { - fn transfer_call_indexes(&self) -> Result<[u8; 2]>; - - fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]>; - - fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl BalancesCallIndexes for NodeMetadata { - fn transfer_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(BALANCES, "transfer") - } - - fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(BALANCES, "transfer_keep_alive") - } - - fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(BALANCES, "transfer_allow_death") - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_proxy.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_proxy.rs deleted file mode 100644 index a0106457b0..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_proxy.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, NodeMetadata}; - -/// Pallet name: -const PROXY: &str = "Proxy"; - -pub trait ProxyCallIndexes { - fn add_proxy_call_indexes(&self) -> Result<[u8; 2]>; - - fn proxy_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl ProxyCallIndexes for NodeMetadata { - fn add_proxy_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(PROXY, "add_proxy") - } - - fn proxy_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(PROXY, "proxy") - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_sidechain.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_sidechain.rs deleted file mode 100644 index c014227dd9..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_sidechain.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, NodeMetadata}; -/// Pallet' name: -pub const SIDECHAIN: &str = "Sidechain"; - -pub trait SidechainCallIndexes { - fn confirm_imported_sidechain_block_indexes(&self) -> Result<[u8; 2]>; -} - -impl SidechainCallIndexes for NodeMetadata { - fn confirm_imported_sidechain_block_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(SIDECHAIN, "confirm_imported_sidechain_block") - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_timestamp.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_timestamp.rs deleted file mode 100644 index 75e695579b..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_timestamp.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, NodeMetadata}; - -/// Pallet' name: -const TIMESTAMP: &str = "Timestamp"; - -pub trait TimestampCallIndexes { - fn timestamp_set_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl TimestampCallIndexes for NodeMetadata { - fn timestamp_set_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(TIMESTAMP, "set") - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_utility.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_utility.rs deleted file mode 100644 index 0eeef1339a..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/pallet_utility.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020-2024 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 crate::{error::Result, NodeMetadata}; - -/// Pallet' name: -const UTIL: &str = "Utility"; - -pub trait UtilityCallIndexes { - fn batch_call_indexes(&self) -> Result<[u8; 2]>; - fn as_derivative_call_indexes(&self) -> Result<[u8; 2]>; - fn batch_all_call_indexes(&self) -> Result<[u8; 2]>; - fn dispatch_as_call_indexes(&self) -> Result<[u8; 2]>; - fn force_batch_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl UtilityCallIndexes for NodeMetadata { - fn batch_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(UTIL, "batch") - } - - fn as_derivative_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(UTIL, "as_derivative") - } - - fn batch_all_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(UTIL, "batch_all") - } - - fn dispatch_as_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(UTIL, "dispatch_as") - } - - fn force_batch_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(UTIL, "force_batch") - } -} diff --git a/tee-worker/identity/core-primitives/node-api/metadata/src/runtime_call.rs b/tee-worker/identity/core-primitives/node-api/metadata/src/runtime_call.rs deleted file mode 100644 index 8fa69cc9ad..0000000000 --- a/tee-worker/identity/core-primitives/node-api/metadata/src/runtime_call.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020-2024 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 crate::{error::Result, Error, NodeMetadata}; -use itp_api_client_types::MetadataError; - -pub trait RuntimeCall { - fn retrieve(&self) -> Result; -} - -impl RuntimeCall for NodeMetadata { - fn retrieve(&self) -> Result { - if self.node_metadata.as_ref().is_none() { - return Err(Error::MetadataNotSet) - } - let node_metadata = self.node_metadata.as_ref().unwrap(); - - let runtime_call = node_metadata.types().types.iter().find(|ty| { - let path = &ty.ty.path.segments; - path.len() == 2 && path[1].as_str() == "RuntimeCall" - }); - - match runtime_call { - Some(runtime_call) => Ok(runtime_call.id), - None => Err(Error::NodeMetadata(MetadataError::CallNotFound("RuntimeCall not found"))), - } - } -} diff --git a/tee-worker/identity/core-primitives/node-api/src/lib.rs b/tee-worker/identity/core-primitives/node-api/src/lib.rs deleted file mode 100644 index aea624c771..0000000000 --- a/tee-worker/identity/core-primitives/node-api/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Re-export crate for all the node-api stuff to simplify downstream imports. - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(feature = "std")] -pub use itp_node_api_factory as node_api_factory; - -pub mod api_client { - #[cfg(feature = "std")] - pub use itp_api_client_extensions::*; - pub use itp_api_client_types::*; -} - -pub mod metadata { - pub use itp_node_api_metadata::*; - pub use itp_node_api_metadata_provider as provider; -} diff --git a/tee-worker/identity/core-primitives/nonce-cache/Cargo.toml b/tee-worker/identity/core-primitives/nonce-cache/Cargo.toml deleted file mode 100644 index e7f3f012fb..0000000000 --- a/tee-worker/identity/core-primitives/nonce-cache/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "itp-nonce-cache" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local dependencies - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/identity/core-primitives/nonce-cache/src/error.rs b/tee-worker/identity/core-primitives/nonce-cache/src/error.rs deleted file mode 100644 index 6b1731a77e..0000000000 --- a/tee-worker/identity/core-primitives/nonce-cache/src/error.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use std::boxed::Box; - -pub type Result = core::result::Result; - -/// nonce cache error -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Nonce lock is poisoned")] - LockPoisoning, - #[error(transparent)] - Other(#[from] Box), -} diff --git a/tee-worker/identity/core-primitives/nonce-cache/src/lib.rs b/tee-worker/identity/core-primitives/nonce-cache/src/lib.rs deleted file mode 100644 index a1e515ac65..0000000000 --- a/tee-worker/identity/core-primitives/nonce-cache/src/lib.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] -#![feature(assert_matches)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -#[cfg(feature = "std")] -use std::sync::RwLockWriteGuard; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; - -use crate::error::Result; - -pub use nonce_cache::NonceCache; - -pub mod error; -pub mod nonce_cache; - -pub type NonceValue = u32; - -/// Nonce type (newtype wrapper for NonceValue) -#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] -pub struct Nonce(pub NonceValue); -/// Trait to mutate a nonce. -/// -/// Used in a combination of loading a lock and then writing the updated -/// value back, returning the lock again. -pub trait MutateNonce { - /// load a nonce with the intention to mutate it. lock is released once it goes out of scope - fn load_for_mutation(&self) -> Result>; -} - -/// Trait to get a nonce. -/// -/// -pub trait GetNonce { - fn get_nonce(&self) -> Result; -} diff --git a/tee-worker/identity/core-primitives/nonce-cache/src/nonce_cache.rs b/tee-worker/identity/core-primitives/nonce-cache/src/nonce_cache.rs deleted file mode 100644 index af55045cd0..0000000000 --- a/tee-worker/identity/core-primitives/nonce-cache/src/nonce_cache.rs +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLock as RwLock; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; - -#[cfg(feature = "std")] -use std::sync::RwLock; -#[cfg(feature = "std")] -use std::sync::RwLockWriteGuard; - -use crate::{ - error::{Error, Result}, - GetNonce, MutateNonce, Nonce, -}; - -/// Local nonce cache -/// -/// stores the nonce internally, protected by a RW lock for concurrent access -#[derive(Default)] -pub struct NonceCache { - nonce_lock: RwLock, -} - -impl NonceCache { - pub fn new(nonce_lock: RwLock) -> Self { - NonceCache { nonce_lock } - } -} - -impl MutateNonce for NonceCache { - fn load_for_mutation(&self) -> Result> { - self.nonce_lock.write().map_err(|_| Error::LockPoisoning) - } -} - -impl GetNonce for NonceCache { - fn get_nonce(&self) -> Result { - let nonce_lock = self.nonce_lock.read().map_err(|_| Error::LockPoisoning)?; - Ok(*nonce_lock) - } -} - -#[cfg(test)] -pub mod tests { - use super::*; - use std::{sync::Arc, thread}; - - #[test] - pub fn nonce_defaults_to_zero() { - let nonce_cache = NonceCache::default(); - assert_eq!(Nonce(0), nonce_cache.get_nonce().unwrap()); - } - - #[test] - pub fn set_nonce_works() { - let nonce_cache = NonceCache::default(); - let mut nonce_lock = nonce_cache.load_for_mutation().unwrap(); - *nonce_lock = Nonce(42); - std::mem::drop(nonce_lock); - assert_eq!(Nonce(42), nonce_cache.get_nonce().unwrap()); - } - - #[test] - pub fn concurrent_read_access_blocks_until_write_is_done() { - let nonce_cache = Arc::new(NonceCache::default()); - - let mut nonce_write_lock = nonce_cache.load_for_mutation().unwrap(); - - // spawn a new thread that reads the nonce - // this thread should be blocked until the write lock is released, i.e. until - // the new nonce is written. We can verify this, by trying to read that nonce variable - // that will be inserted further down below - let new_thread_nonce_cache = nonce_cache.clone(); - let join_handle = thread::spawn(move || { - let nonce_read = new_thread_nonce_cache.get_nonce().unwrap(); - assert_eq!(Nonce(3108), nonce_read); - }); - - *nonce_write_lock = Nonce(3108); - std::mem::drop(nonce_write_lock); - - join_handle.join().unwrap(); - } -} diff --git a/tee-worker/identity/core-primitives/ocall-api/Cargo.toml b/tee-worker/identity/core-primitives/ocall-api/Cargo.toml deleted file mode 100644 index 0816ed4a88..0000000000 --- a/tee-worker/identity/core-primitives/ocall-api/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "itp-ocall-api" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } - -# sgx deps -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate deps -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-storage = { path = "../storage", default-features = false } -itp-types = { path = "../types", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "itp-storage/std", - "itp-types/std", -] diff --git a/tee-worker/identity/core-primitives/primitives-cache/Cargo.toml b/tee-worker/identity/core-primitives/primitives-cache/Cargo.toml deleted file mode 100644 index 09c1a30401..0000000000 --- a/tee-worker/identity/core-primitives/primitives-cache/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "itp-primitives-cache" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local dependencies - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } - -[features] -default = ["std"] -std = [ - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/identity/core-primitives/primitives-cache/src/error.rs b/tee-worker/identity/core-primitives/primitives-cache/src/error.rs deleted file mode 100644 index 2873dd8156..0000000000 --- a/tee-worker/identity/core-primitives/primitives-cache/src/error.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use std::boxed::Box; - -pub type Result = core::result::Result; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Primitives lock is poisoned")] - LockPoisoning, - #[error(transparent)] - Other(#[from] Box), -} diff --git a/tee-worker/identity/core-primitives/primitives-cache/src/lib.rs b/tee-worker/identity/core-primitives/primitives-cache/src/lib.rs deleted file mode 100644 index e4a2724e3f..0000000000 --- a/tee-worker/identity/core-primitives/primitives-cache/src/lib.rs +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Stores all primitives of the enclave that do need to be accessed often, but are -//! not be frequently mutated, such as keys and server urls. -//! -//! TODO: For now only the mu-ra server and untrusted worker url is stored here. Keys and such could also be stored here. - -#![cfg_attr(not(feature = "std"), no_std)] -#![feature(assert_matches)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// Re-export module to properly feature gate sgx and regular std environment. -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -#[cfg(feature = "std")] -use std::sync::RwLockReadGuard; -#[cfg(feature = "std")] -use std::sync::RwLockWriteGuard; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockReadGuard as RwLockReadGuard; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use std::sync::SgxRwLockWriteGuard as RwLockWriteGuard; - -use crate::error::Result; -use lazy_static::lazy_static; -use std::{string::String, sync::Arc}; - -pub use primitives_cache::PrimitivesCache; - -lazy_static! { - /// Global instance of the primitives cache. - /// - /// Concurrent access is managed internally, using RW locks. - pub static ref GLOBAL_PRIMITIVES_CACHE: Arc = Default::default(); -} - -pub mod error; -pub mod primitives_cache; - -#[derive(Default, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] -pub struct Primitives { - mu_ra_url: String, - untrusted_worker_url: String, -} - -impl Primitives { - pub fn new(mu_ra_url: String, untrusted_worker_url: String) -> Primitives { - Primitives { mu_ra_url, untrusted_worker_url } - } - - pub fn mu_ra_url(&self) -> &str { - &self.mu_ra_url - } - - pub fn untrusted_worker_url(&self) -> &str { - &self.untrusted_worker_url - } -} - -/// Trait to mutate the primitives. -/// -/// Used in a combination of loading a lock and then writing the updated -/// value back, returning the lock again. -pub trait MutatePrimitives { - fn load_for_mutation(&self) -> Result>; -} - -/// Trait to get the primitives. -pub trait GetPrimitives { - /// Returns a clone of the full Primitives struct. - fn get_primitives(&self) -> Result>; - - fn get_mu_ra_url(&self) -> Result; - - fn get_untrusted_worker_url(&self) -> Result; -} - -// Helper function to set primitives of a given cache. -pub fn set_primitives( - cache: &E, - mu_ra_url: String, - untrusted_worker_url: String, -) -> Result<()> { - let primitives = Primitives::new(mu_ra_url, untrusted_worker_url); - let mut rw_lock = cache.load_for_mutation()?; - - *rw_lock = primitives; - - Ok(()) -} diff --git a/tee-worker/identity/core-primitives/rpc/Cargo.toml b/tee-worker/identity/core-primitives/rpc/Cargo.toml deleted file mode 100644 index 6db2e13890..0000000000 --- a/tee-worker/identity/core-primitives/rpc/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "itp-rpc" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -itp-types = { default-features = false, path = "../types" } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-types/std", - "serde/std", - "serde_json/std", -] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/identity/core-primitives/sgx-runtime-primitives/Cargo.toml b/tee-worker/identity/core-primitives/sgx-runtime-primitives/Cargo.toml deleted file mode 100644 index 510d51a270..0000000000 --- a/tee-worker/identity/core-primitives/sgx-runtime-primitives/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "itp-sgx-runtime-primitives" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] - -# Substrate dependencies -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "frame-system/std", - "pallet-balances/std", - "sp-core/std", - "sp-runtime/std", -] diff --git a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/constants.rs b/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/constants.rs deleted file mode 100644 index 75eac384f1..0000000000 --- a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/constants.rs +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::types::{BlockNumber, Moment}; - -pub const ONE_DAY: Moment = 86_400_000; - -pub const MILLISECS_PER_BLOCK: u64 = 6000; - -pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; - -// Time is measured by number of blocks. -pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); -pub const HOURS: BlockNumber = MINUTES * 60; -pub const DAYS: BlockNumber = HOURS * 24; diff --git a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/lib.rs b/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/lib.rs deleted file mode 100644 index 74007111ba..0000000000 --- a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -pub mod constants; -pub mod types; diff --git a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/types.rs b/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/types.rs deleted file mode 100644 index 035ae982b8..0000000000 --- a/tee-worker/identity/core-primitives/sgx-runtime-primitives/src/types.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 sp_runtime::{ - generic::{self, Block as BlockG, SignedBlock as SignedBlockG}, - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, OpaqueExtrinsic, -}; - -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this sgx-runtime. -pub type Header = generic::Header; - -/// An index to a block. -pub type BlockNumber = u32; -pub type SidechainBlockNumber = u64; -pub type SidechainTimestamp = u64; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -pub type AccountData = pallet_balances::AccountData; -pub type AccountInfo = frame_system::AccountInfo; - -/// The type for looking up accounts. We don't expect more than 4 billion of them, but you -/// never know... -pub type AccountIndex = u32; - -/// Balance of an account. -pub type Balance = u128; - -/// Index of a transaction in the chain. -pub type Index = u32; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -/// Digest item type. -pub type DigestItem = generic::DigestItem; - -/// A type to hold UTC unix epoch [ms] -pub type Moment = u64; - -pub type Block = BlockG; -pub type SignedBlock = SignedBlockG; -pub type BlockHash = sp_core::H256; -pub type ShardIdentifier = sp_core::H256; diff --git a/tee-worker/identity/core-primitives/sgx/crypto/Cargo.toml b/tee-worker/identity/core-primitives/sgx/crypto/Cargo.toml deleted file mode 100644 index 5fac50e7d7..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/Cargo.toml +++ /dev/null @@ -1,56 +0,0 @@ -[package] -name = "itp-sgx-crypto" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -aes = { version = "0.6.0" } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -log = { version = "0.4", default-features = false } -ofb = { version = "0.4.0" } -serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true } - -# sgx deps -serde_json-sgx = { package = "serde_json", tag = "sgx_1.1.3", git = "https://github.com/mesalock-linux/serde-json-sgx", optional = true } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-sgx-io = { path = "../io", default-features = false } - -# test sgx deps -itp-sgx-temp-dir = { default-features = false, optional = true, path = "../temp-dir" } - -[features] -default = ["std"] -std = [ - "codec/std", - "log/std", - "itp-sgx-io/std", - "sp-core/std", - "serde_json/std", - "sgx-crypto-helper/default", -] -sgx = [ - "sgx-crypto-helper/mesalock_sgx", - "sgx_tstd", - "sgx_rand", - "itp-sgx-io/sgx", - "serde_json-sgx", -] -mocks = [] -test = [ - # features - "mocks", - "sgx", - # deps - "itp-sgx-temp-dir", -] diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/aes.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/aes.rs deleted file mode 100644 index 0c1414e84c..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/aes.rs +++ /dev/null @@ -1,203 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::{Error, Result}, - traits::StateCrypto, -}; -use aes::Aes128; -use codec::{Decode, Encode}; -use ofb::{ - cipher::{NewStreamCipher, SyncStreamCipher}, - Ofb, -}; -use std::{ - convert::{TryFrom, TryInto}, - path::PathBuf, -}; - -type AesOfb = Ofb; - -/// File name of the sealed AES key data. -pub const AES_KEY_FILE_AND_INIT_V: &str = "aes_key_and_iv_sealed_data.bin"; - -#[derive(Debug, Default, Encode, Decode, Clone, Copy, PartialEq, Eq)] -pub struct Aes { - pub key: [u8; 16], - pub init_vec: [u8; 16], -} - -impl Aes { - pub fn new(key: [u8; 16], init_vec: [u8; 16]) -> Self { - Self { key, init_vec } - } -} - -#[derive(Clone, Debug)] -pub struct AesSeal { - base_path: PathBuf, -} - -impl AesSeal { - pub fn new(base_path: PathBuf) -> Self { - Self { base_path } - } - - pub fn path(&self) -> PathBuf { - self.base_path.join(AES_KEY_FILE_AND_INIT_V) - } -} - -impl StateCrypto for Aes { - type Error = Error; - - fn encrypt(&self, data: &mut [u8]) -> Result<()> { - de_or_encrypt(self, data) - } - - fn decrypt(&self, data: &mut [u8]) -> Result<()> { - de_or_encrypt(self, data) - } -} - -impl TryFrom<&Aes> for AesOfb { - type Error = Error; - - fn try_from(aes: &Aes) -> std::result::Result { - AesOfb::new_var(&aes.key, &aes.init_vec).map_err(|_| Error::InvalidNonceKeyLength) - } -} - -/// If AES acts on the encrypted data it decrypts and vice versa -pub fn de_or_encrypt(aes: &Aes, data: &mut [u8]) -> Result<()> { - aes.try_into().map(|mut ofb: AesOfb| ofb.apply_keystream(data)) -} - -pub trait AesSealing { - fn unseal_key(&self) -> Result; - - fn exists(&self) -> bool; - - fn create_sealed_if_absent(&self) -> Result<()>; - - fn create_sealed(&self) -> Result<()>; -} - -#[cfg(feature = "sgx")] -pub use sgx::*; - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::*; - use crate::key_repository::KeyRepository; - use itp_sgx_io::{seal, unseal, SealedIO}; - use log::info; - use sgx_rand::{Rng, StdRng}; - use std::sgxfs::SgxFile; - - /// Gets a repository for an AES key and initializes - /// a fresh key if it doesn't exist at `path`. - pub fn get_aes_repository(path: PathBuf) -> Result> { - let aes_seal = AesSeal::new(path); - aes_seal.create_sealed_if_absent()?; - let aes_key = aes_seal.unseal_key()?; - Ok(KeyRepository::new(aes_key, aes_seal.into())) - } - - impl AesSealing for AesSeal { - fn unseal_key(&self) -> Result { - self.unseal() - } - - fn exists(&self) -> bool { - SgxFile::open(self.path()).is_ok() - } - - fn create_sealed_if_absent(&self) -> Result<()> { - if !self.exists() { - info!("Keyfile not found, creating new! {}", self.path().display()); - return self.create_sealed() - } - Ok(()) - } - - fn create_sealed(&self) -> Result<()> { - let mut key = [0u8; 16]; - let mut iv = [0u8; 16]; - let mut rand = StdRng::new()?; - - rand.fill_bytes(&mut key); - rand.fill_bytes(&mut iv); - - Ok(self.seal(&Aes::new(key, iv))?) - } - } - - impl SealedIO for AesSeal { - type Error = Error; - type Unsealed = Aes; - - fn unseal(&self) -> Result { - Ok(unseal(self.path()).map(|b| Decode::decode(&mut b.as_slice()))??) - } - - fn seal(&self, unsealed: &Self::Unsealed) -> Result<()> { - Ok(unsealed.using_encoded(|bytes| seal(bytes, self.path()))?) - } - } -} - -#[cfg(feature = "test")] -pub mod sgx_tests { - use super::sgx::*; - use crate::{key_repository::AccessKey, AesSeal, AesSealing}; - use itp_sgx_temp_dir::TempDir; - - pub fn using_get_aes_repository_twice_initializes_key_only_once() { - let temp_dir = - TempDir::with_prefix("using_get_aes_repository_twice_initializes_key_only_once") - .unwrap(); - let temp_path = temp_dir.path().to_path_buf(); - let key1 = get_aes_repository(temp_path.clone()).unwrap().retrieve_key().unwrap(); - let key2 = get_aes_repository(temp_path).unwrap().retrieve_key().unwrap(); - assert_eq!(key1, key2); - } - - pub fn aes_sealing_works() { - let temp_dir = TempDir::with_prefix("aes_sealing_works").unwrap(); - let seal = AesSeal::new(temp_dir.path().to_path_buf()); - - // Create new sealed keys and unseal them - assert!(!seal.exists()); - seal.create_sealed_if_absent().unwrap(); - let key = seal.unseal_key().unwrap(); - - assert!(seal.exists()); - - // Should not change anything because the key is already there. - seal.create_sealed_if_absent().unwrap(); - let key_same = seal.unseal_key().unwrap(); - - assert_eq!(key, key_same); - - // Should overwrite previous keys. - seal.create_sealed().unwrap(); - let key_different = seal.unseal_key().unwrap(); - - assert_ne!(key_different, key); - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519.rs deleted file mode 100644 index 153314eb4f..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519.rs +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::{Error, Result}, - ToPubkey, -}; -use sp_core::ed25519; - -#[cfg(feature = "sgx")] -pub use sgx::*; - -/// File name of the sealed Ed25519 seed file. -pub const SEALED_SIGNER_SEED_FILE: &str = "ed25519_key_sealed.bin"; - -pub trait Ed25519Sealing { - fn unseal_pubkey(&self) -> Result; - - fn unseal_pair(&self) -> Result; - - fn exists(&self) -> bool; - - fn create_sealed_if_absent(&self) -> Result<()>; - - fn create_sealed(&self) -> Result<()>; -} - -impl ToPubkey for ed25519::Pair { - type Error = Error; - type Pubkey = ed25519::Public; - - fn pubkey(&self) -> Result { - Ok((*self).into()) - } -} - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::SEALED_SIGNER_SEED_FILE; - use crate::{ - error::{Error, Result}, - key_repository::KeyRepository, - Ed25519Sealing, - }; - use codec::Encode; - use itp_sgx_io::{seal, unseal, SealedIO}; - use log::*; - use sgx_rand::{Rng, StdRng}; - use sp_core::{crypto::Pair, ed25519}; - use std::path::PathBuf; - - /// Gets a repository for an Ed25519 keypair and initializes - /// a fresh key pair if it doesn't exist at `path`. - pub fn get_ed25519_repository( - path: PathBuf, - ) -> Result> { - let ed25519_seal = Ed25519Seal::new(path); - ed25519_seal.create_sealed_if_absent()?; - let signing_pair = ed25519_seal.unseal_pair()?; - Ok(KeyRepository::new(signing_pair, ed25519_seal.into())) - } - - #[derive(Clone, Debug)] - pub struct Ed25519Seal { - base_path: PathBuf, - } - - impl Ed25519Seal { - pub fn new(base_path: PathBuf) -> Self { - Self { base_path } - } - - pub fn path(&self) -> PathBuf { - self.base_path.join(SEALED_SIGNER_SEED_FILE) - } - } - - impl Ed25519Sealing for Ed25519Seal { - fn unseal_pubkey(&self) -> Result { - self.unseal().map(Into::into) - } - - fn unseal_pair(&self) -> Result { - self.unseal() - } - - fn exists(&self) -> bool { - self.path().exists() - } - - fn create_sealed_if_absent(&self) -> Result<()> { - if !self.exists() { - info!("Keyfile not found, creating new! {}", self.path().display()); - return self.create_sealed() - } - Ok(()) - } - - fn create_sealed(&self) -> Result<()> { - let mut seed = [0u8; 32]; - let mut rand = StdRng::new()?; - rand.fill_bytes(&mut seed); - - Ok(seal(&seed, self.path())?) - } - } - - impl SealedIO for Ed25519Seal { - type Error = Error; - type Unsealed = ed25519::Pair; - - fn unseal(&self) -> Result { - let raw = unseal(self.path())?; - - ed25519::Pair::from_seed_slice(&raw) - .map_err(|e| Error::Other(format!("{:?}", e).into())) - } - - fn seal(&self, unsealed: &Self::Unsealed) -> Result<()> { - Ok(unsealed.seed().using_encoded(|bytes| seal(bytes, self.path()))?) - } - } -} - -#[cfg(feature = "test")] -pub mod sgx_tests { - use super::sgx::*; - use crate::{key_repository::AccessKey, Ed25519Sealing, ToPubkey}; - use itp_sgx_temp_dir::TempDir; - - pub fn using_get_ed25519_repository_twice_initializes_key_only_once() { - let temp_dir = - TempDir::with_prefix("using_get_rsa3072_repository_twice_initializes_key_only_once") - .unwrap(); - let temp_path = temp_dir.path().to_path_buf(); - let key1 = get_ed25519_repository(temp_path.clone()).unwrap().retrieve_key().unwrap(); - let key2 = get_ed25519_repository(temp_path).unwrap().retrieve_key().unwrap(); - assert_eq!(key1.pubkey().unwrap(), key2.pubkey().unwrap()); - } - - pub fn ed25529_sealing_works() { - let temp_dir = TempDir::with_prefix("ed25529_sealing_works").unwrap(); - let seal = Ed25519Seal::new(temp_dir.path().to_path_buf()); - - // Create new sealed keys and unseal them. - assert!(!seal.exists()); - seal.create_sealed_if_absent().unwrap(); - let pair = seal.unseal_pair().unwrap(); - let pubkey = seal.unseal_pubkey().unwrap(); - - assert!(seal.exists()); - assert_eq!(pair.pubkey().unwrap(), pubkey); - - // Should not change anything because the key is already there. - seal.create_sealed_if_absent().unwrap(); - let pair_same = seal.unseal_pair().unwrap(); - - assert_eq!(pair.pubkey().unwrap(), pair_same.pubkey().unwrap()); - - // Should overwrite previous keys. - seal.create_sealed().unwrap(); - let pair_different = seal.unseal_pair().unwrap(); - - assert_ne!(pair_different.pubkey().unwrap(), pair.pubkey().unwrap()); - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519_derivation.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519_derivation.rs deleted file mode 100644 index 25e51279c7..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/ed25519_derivation.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::error::Result; -use sgx_crypto_helper::rsa3072::Rsa3072KeyPair; -use sp_core::{blake2_256, ed25519::Pair as Ed25519Pair, Pair}; - -/// Trait to derive an Ed25519 key pair. -pub trait DeriveEd25519 { - fn derive_ed25519(&self) -> Result; -} - -impl DeriveEd25519 for Rsa3072KeyPair { - fn derive_ed25519(&self) -> Result { - let encoded_key = serde_json::to_vec(self)?; - let seed = blake2_256(&encoded_key); - Ok(Ed25519Pair::from_seed(&seed)) - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/error.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/error.rs deleted file mode 100644 index 4fa619d136..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/error.rs +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use derive_more::{Display, From}; -use sgx_types::sgx_status_t; -use std::prelude::v1::Box; - -#[derive(Debug, Display, From)] -pub enum Error { - IO(std::io::Error), - InvalidNonceKeyLength, - Codec(codec::Error), - Serialization(serde_json::Error), - LockPoisoning, - Other(Box), -} - -pub type Result = core::result::Result; - -impl From for sgx_status_t { - /// return sgx_status for top level enclave functions - fn from(error: Error) -> sgx_status_t { - log::warn!("Transform non-sgx-error into `SGX_ERROR_UNEXPECTED`: {:?}", error); - sgx_status_t::SGX_ERROR_UNEXPECTED - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/key_repository.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/key_repository.rs deleted file mode 100644 index 41ca5ae860..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/key_repository.rs +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - ToPubkey, -}; -use itp_sgx_io::SealedIO; -use std::sync::Arc; - -/// Access a cryptographic key. -pub trait AccessKey { - type KeyType; - - fn retrieve_key(&self) -> Result; -} - -/// Access a cryptographic public key. -pub trait AccessPubkey { - type KeyType; - - fn retrieve_pubkey(&self) -> Result; -} - -/// Mutate a cryptographic key. -pub trait MutateKey { - fn update_key(&self, key: KeyType) -> Result<()>; -} - -/// Repository implementation. Stores a cryptographic key in-memory and in a file backed. -/// Uses the SealedIO trait for the file backend. -pub struct KeyRepository { - key_lock: RwLock, - sealed_io: Arc, -} - -impl KeyRepository { - pub fn new(key: KeyType, sealed_io: Arc) -> Self { - KeyRepository { key_lock: RwLock::new(key), sealed_io } - } -} - -impl AccessKey for KeyRepository -where - KeyType: Clone, - SealedIo: SealedIO, -{ - type KeyType = KeyType; - - fn retrieve_key(&self) -> Result { - self.key_lock.read().map_err(|_| Error::LockPoisoning).map(|l| l.clone()) - } -} - -impl AccessPubkey for KeyRepository -where - Pair: ToPubkey + Clone, - SealedIo: SealedIO, -{ - type KeyType = ::Pubkey; - - fn retrieve_pubkey(&self) -> Result { - self.key_lock.read().map_err(|_| Error::LockPoisoning).map(|p| p.pubkey())? - } -} - -impl MutateKey for KeyRepository -where - KeyType: Clone, - SealedIo: SealedIO, -{ - fn update_key(&self, key: KeyType) -> Result<()> { - let mut key_lock = self.key_lock.write().map_err(|_| Error::LockPoisoning)?; - - self.sealed_io.seal(&key)?; - *key_lock = self.sealed_io.unseal()?; - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{aes::Aes, mocks::AesSealMock}; - - type TestKeyRepository = KeyRepository; - - #[test] - fn update_and_retrieve_key_works() { - let seal_mock = Arc::new(AesSealMock::default()); - let key_repository = TestKeyRepository::new(seal_mock.unseal().unwrap(), seal_mock.clone()); - - assert_eq!(seal_mock.unseal().unwrap(), key_repository.retrieve_key().unwrap()); - - let updated_key = Aes::new([2u8; 16], [0u8; 16]); - key_repository.update_key(updated_key).unwrap(); - - assert_eq!(updated_key, key_repository.retrieve_key().unwrap()); - assert_eq!(updated_key, seal_mock.unseal().unwrap()); - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/lib.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/lib.rs deleted file mode 100644 index 832239c027..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/lib.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! All the different crypto schemes that we use in sgx - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -#[macro_use] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use serde_json_sgx as serde_json; -} - -pub mod aes; -pub mod ed25519; -pub mod ed25519_derivation; -pub mod error; -pub mod key_repository; -pub mod rsa3072; -pub mod traits; - -pub use self::{aes::*, ed25519::*, rsa3072::*}; -pub use error::*; -pub use traits::*; - -#[cfg(feature = "mocks")] -pub mod mocks; - -#[cfg(feature = "test")] -pub mod tests { - pub use super::ed25519::sgx_tests::{ - ed25529_sealing_works, using_get_ed25519_repository_twice_initializes_key_only_once, - }; - - pub use super::rsa3072::sgx_tests::{ - rsa3072_sealing_works, using_get_rsa3072_repository_twice_initializes_key_only_once, - }; - - pub use super::aes::sgx_tests::{ - aes_sealing_works, using_get_aes_repository_twice_initializes_key_only_once, - }; -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/mocks.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/mocks.rs deleted file mode 100644 index 0e199378fd..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/mocks.rs +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - aes::Aes, - error::{Error, Result}, - key_repository::{AccessKey, MutateKey}, -}; -use itp_sgx_io::{SealedIO, StaticSealedIO}; -use sgx_crypto_helper::rsa3072::Rsa3072KeyPair; - -#[derive(Default)] -pub struct KeyRepositoryMock -where - KeyType: Clone + Default, -{ - key: RwLock, -} - -impl KeyRepositoryMock -where - KeyType: Clone + Default, -{ - pub fn new(key: KeyType) -> Self { - KeyRepositoryMock { key: RwLock::new(key) } - } -} - -impl AccessKey for KeyRepositoryMock -where - KeyType: Clone + Default, -{ - type KeyType = KeyType; - - fn retrieve_key(&self) -> Result { - Ok(self.key.read().unwrap().clone()) - } -} - -impl MutateKey for KeyRepositoryMock -where - KeyType: Clone + Default, -{ - fn update_key(&self, key: KeyType) -> Result<()> { - let mut lock = self.key.write().unwrap(); - *lock = key; - Ok(()) - } -} - -#[derive(Default)] -pub struct AesSealMock { - aes: RwLock, -} - -impl StaticSealedIO for AesSealMock { - type Error = Error; - type Unsealed = Aes; - - fn unseal_from_static_file() -> Result { - Ok(Aes::default()) - } - - fn seal_to_static_file(_unsealed: &Self::Unsealed) -> Result<()> { - Ok(()) - } -} - -impl SealedIO for AesSealMock { - type Error = Error; - type Unsealed = Aes; - - fn unseal(&self) -> std::result::Result { - self.aes.read().map_err(|e| Error::Other(format!("{:?}", e).into())).map(|k| *k) - } - - fn seal(&self, unsealed: &Self::Unsealed) -> Result<()> { - let mut aes_lock = self.aes.write().map_err(|e| Error::Other(format!("{:?}", e).into()))?; - *aes_lock = *unsealed; - Ok(()) - } -} - -#[derive(Default)] -pub struct Rsa3072SealMock {} - -impl StaticSealedIO for Rsa3072SealMock { - type Error = Error; - type Unsealed = Rsa3072KeyPair; - - fn unseal_from_static_file() -> Result { - Ok(Rsa3072KeyPair::default()) - } - - fn seal_to_static_file(_unsealed: &Self::Unsealed) -> Result<()> { - Ok(()) - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/rsa3072.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/rsa3072.rs deleted file mode 100644 index 3a63a0d11d..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/rsa3072.rs +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{ - error::{Error, Result}, - traits::{ShieldingCryptoDecrypt, ShieldingCryptoEncrypt}, - ToPubkey, -}; -use sgx_crypto_helper::{ - rsa3072::{Rsa3072KeyPair, Rsa3072PubKey}, - RsaKeyPair, -}; -use std::vec::Vec; - -// Reexport sgx module -#[cfg(feature = "sgx")] -pub use sgx::*; - -/// File name of the sealed RSA key file. -pub const RSA3072_SEALED_KEY_FILE: &str = "rsa3072_key_sealed.bin"; - -impl ShieldingCryptoEncrypt for Rsa3072KeyPair { - type Error = Error; - - fn encrypt(&self, data: &[u8]) -> Result> { - let mut cipher_buffer = Vec::new(); - self.encrypt_buffer(data, &mut cipher_buffer) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(cipher_buffer) - } -} - -impl ShieldingCryptoDecrypt for Rsa3072KeyPair { - type Error = Error; - - fn decrypt(&self, data: &[u8]) -> Result> { - let mut decrypted_buffer = Vec::new(); - self.decrypt_buffer(data, &mut decrypted_buffer) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(decrypted_buffer) - } -} - -impl ShieldingCryptoEncrypt for Rsa3072PubKey { - type Error = Error; - - fn encrypt(&self, data: &[u8]) -> Result> { - let mut cipher_buffer = Vec::new(); - self.encrypt_buffer(data, &mut cipher_buffer) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(cipher_buffer) - } -} - -impl ToPubkey for Rsa3072KeyPair { - type Error = Error; - type Pubkey = Rsa3072PubKey; - - fn pubkey(&self) -> Result { - self.export_pubkey().map_err(|e| Error::Other(format!("{:?}", e).into())) - } -} - -pub trait RsaSealing { - fn unseal_pubkey(&self) -> Result; - - fn unseal_pair(&self) -> Result; - - fn exists(&self) -> bool; - - fn create_sealed_if_absent(&self) -> Result<()>; - - fn create_sealed(&self) -> Result<()>; -} - -#[cfg(feature = "sgx")] -pub mod sgx { - use super::*; - use crate::key_repository::KeyRepository; - use itp_sgx_io::{seal, unseal, SealedIO}; - use log::*; - use std::path::PathBuf; - - /// Gets a repository for an Rsa3072 keypair and initializes - /// a fresh key pair if it doesn't exist at `path`. - pub fn get_rsa3072_repository( - path: PathBuf, - ) -> Result> { - let rsa_seal = Rsa3072Seal::new(path); - rsa_seal.create_sealed_if_absent()?; - let shielding_key = rsa_seal.unseal_pair()?; - Ok(KeyRepository::new(shielding_key, rsa_seal.into())) - } - - #[derive(Clone, Debug)] - pub struct Rsa3072Seal { - base_path: PathBuf, - } - - impl Rsa3072Seal { - pub fn new(base_path: PathBuf) -> Self { - Self { base_path } - } - - pub fn path(&self) -> PathBuf { - self.base_path.join(RSA3072_SEALED_KEY_FILE) - } - } - - impl RsaSealing for Rsa3072Seal { - fn unseal_pubkey(&self) -> Result { - self.unseal()?.pubkey() - } - - fn unseal_pair(&self) -> Result { - self.unseal() - } - - fn exists(&self) -> bool { - self.path().exists() - } - - fn create_sealed_if_absent(&self) -> Result<()> { - if !self.exists() { - info!("Keyfile not found, creating new! {}", self.path().display()); - return self.create_sealed() - } - Ok(()) - } - - fn create_sealed(&self) -> Result<()> { - let rsa_keypair = - Rsa3072KeyPair::new().map_err(|e| Error::Other(format!("{:?}", e).into()))?; - info!("Generated RSA3072 key pair. PubKey: {:?}", rsa_keypair.pubkey()?); - self.seal(&rsa_keypair) - } - } - - impl SealedIO for Rsa3072Seal { - type Error = Error; - type Unsealed = Rsa3072KeyPair; - - fn unseal(&self) -> Result { - let raw = unseal(self.path())?; - let key: Rsa3072KeyPair = serde_json::from_slice(&raw) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(key.into()) - } - - fn seal(&self, unsealed: &Self::Unsealed) -> Result<()> { - let key_json = serde_json::to_vec(&unsealed) - .map_err(|e| Error::Other(format!("{:?}", e).into()))?; - Ok(seal(&key_json, self.path())?) - } - } -} - -#[cfg(feature = "test")] -pub mod sgx_tests { - use super::{serde_json, sgx::*}; - use crate::{key_repository::AccessKey, RsaSealing, ToPubkey}; - use itp_sgx_temp_dir::TempDir; - use sgx_crypto_helper::rsa3072::Rsa3072PubKey; - - /// Helper method because Rsa3072 does not implement `Eq`. - pub fn equal(pubkey1: &Rsa3072PubKey, pubkey2: &Rsa3072PubKey) -> bool { - serde_json::to_vec(pubkey1).unwrap() == serde_json::to_vec(pubkey2).unwrap() - } - - pub fn using_get_rsa3072_repository_twice_initializes_key_only_once() { - let temp_dir = - TempDir::with_prefix("using_get_rsa3072_repository_twice_initializes_key_only_once") - .unwrap(); - let temp_path = temp_dir.path().to_path_buf(); - let key1 = get_rsa3072_repository(temp_path.clone()).unwrap().retrieve_key().unwrap(); - let key2 = get_rsa3072_repository(temp_path).unwrap().retrieve_key().unwrap(); - assert!(equal(&key1.pubkey().unwrap(), &key2.pubkey().unwrap())); - } - - pub fn rsa3072_sealing_works() { - let temp_dir = TempDir::with_prefix("rsa3072_sealing_works").unwrap(); - let seal = Rsa3072Seal::new(temp_dir.path().to_path_buf()); - - // Create new sealed keys and unseal them - assert!(!seal.exists()); - seal.create_sealed_if_absent().unwrap(); - let pair = seal.unseal_pair().unwrap(); - let pubkey = seal.unseal_pubkey().unwrap(); - - assert!(seal.exists()); - assert!(equal(&pair.pubkey().unwrap(), &pubkey)); - - // Should not change anything because the key is already there. - seal.create_sealed_if_absent().unwrap(); - let pair_same = seal.unseal_pair().unwrap(); - - assert!(equal(&pair.pubkey().unwrap(), &pair_same.pubkey().unwrap())); - - // Should overwrite previous keys. - seal.create_sealed().unwrap(); - let pair_different = seal.unseal_pair().unwrap(); - - assert!(!equal(&pair_different.pubkey().unwrap(), &pair.pubkey().unwrap())); - } -} diff --git a/tee-worker/identity/core-primitives/sgx/crypto/src/traits.rs b/tee-worker/identity/core-primitives/sgx/crypto/src/traits.rs deleted file mode 100644 index 1d0aef5798..0000000000 --- a/tee-worker/identity/core-primitives/sgx/crypto/src/traits.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Abstraction over the state crypto that is used in the enclave -use std::{fmt::Debug, vec::Vec}; - -pub trait StateCrypto { - type Error: Debug; - fn encrypt(&self, data: &mut [u8]) -> Result<(), Self::Error>; - fn decrypt(&self, data: &mut [u8]) -> Result<(), Self::Error>; -} - -pub trait ShieldingCryptoEncrypt { - type Error: Debug; - fn encrypt(&self, data: &[u8]) -> Result, Self::Error>; -} - -pub trait ShieldingCryptoDecrypt { - type Error: Debug; - fn decrypt(&self, data: &[u8]) -> Result, Self::Error>; -} - -pub trait ToPubkey { - type Error: Debug; - type Pubkey; - - fn pubkey(&self) -> Result; -} diff --git a/tee-worker/identity/core-primitives/sgx/io/Cargo.toml b/tee-worker/identity/core-primitives/sgx/io/Cargo.toml deleted file mode 100644 index 9c358d438b..0000000000 --- a/tee-worker/identity/core-primitives/sgx/io/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "itp-sgx-io" -version = "0.8.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - -# sgx deps -sgx_tstd = { optional = true, features = ["untrusted_fs"], branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -[features] -default = ["std"] -std = [] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/identity/core-primitives/sgx/io/src/lib.rs b/tee-worker/identity/core-primitives/sgx/io/src/lib.rs deleted file mode 100644 index 4f6d4eaa35..0000000000 --- a/tee-worker/identity/core-primitives/sgx/io/src/lib.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! SGX file IO abstractions - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -use std::{ - convert::AsRef, - fs, - io::{Read, Result as IOResult, Write}, - path::Path, - string::String, - vec::Vec, -}; - -#[cfg(feature = "sgx")] -pub use sgx::*; - -/// Abstraction around IO that is supposed to use the `std::io::File` -pub trait IO: Sized { - type Error: From + std::fmt::Debug + 'static; - - fn read() -> Result; - fn write(&self) -> Result<(), Self::Error>; -} - -/// Abstraction around IO that is supposed to use `SgxFile`. We expose it also in `std` to -/// be able to put it as trait bounds in `std` and use it in tests. -/// -/// This is the static method (or associated function) version, should be made obsolete over time, -/// since it has state, but hides it in a global state. Makes it difficult to mock. -pub trait StaticSealedIO: Sized { - type Error: From + std::fmt::Debug + 'static; - - /// Type that is unsealed. - type Unsealed; - - fn unseal_from_static_file() -> Result; - fn seal_to_static_file(unsealed: &Self::Unsealed) -> Result<(), Self::Error>; -} - -/// Abstraction around IO that is supposed to use `SgxFile`. We expose it also in `std` to -/// be able to put it as trait bounds in `std` and use it in tests. -/// -pub trait SealedIO: Sized { - type Error: From + std::fmt::Debug + 'static; - - /// Type that is unsealed. - type Unsealed; - - fn unseal(&self) -> Result; - fn seal(&self, unsealed: &Self::Unsealed) -> Result<(), Self::Error>; -} - -pub fn read>(path: P) -> IOResult> { - let mut buf = Vec::new(); - fs::File::open(path).map(|mut f| f.read_to_end(&mut buf))??; - Ok(buf) -} - -pub fn write>(bytes: &[u8], path: P) -> IOResult<()> { - fs::File::create(path).map(|mut f| f.write_all(bytes))? -} - -pub fn read_to_string>(filepath: P) -> IOResult { - let mut contents = String::new(); - fs::File::open(filepath).map(|mut f| f.read_to_string(&mut contents))??; - Ok(contents) -} - -#[cfg(feature = "sgx")] -mod sgx { - use std::{ - convert::AsRef, - io::{Read, Result, Write}, - path::Path, - sgxfs::SgxFile, - vec::Vec, - }; - - pub fn unseal>(path: P) -> Result> { - let mut buf = Vec::new(); - SgxFile::open(path).map(|mut f| f.read_to_end(&mut buf))??; - Ok(buf) - } - - pub fn seal>(bytes: &[u8], path: P) -> Result<()> { - SgxFile::create(path).map(|mut f| f.write_all(bytes))? - } -} diff --git a/tee-worker/identity/core-primitives/sgx/temp-dir/Cargo.toml b/tee-worker/identity/core-primitives/sgx/temp-dir/Cargo.toml deleted file mode 100644 index c86fcafbd1..0000000000 --- a/tee-worker/identity/core-primitives/sgx/temp-dir/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "itp-sgx-temp-dir" -version = "0.1.0" -edition = "2021" - -[dependencies] -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[dev-dependencies.safe-lock] -version = "^0.1" - -[features] -default = ["std"] -std = [] -sgx = [ - "sgx_tstd", -] diff --git a/tee-worker/identity/core-primitives/sgx/temp-dir/src/lib.rs b/tee-worker/identity/core-primitives/sgx/temp-dir/src/lib.rs deleted file mode 100644 index f8332fb74f..0000000000 --- a/tee-worker/identity/core-primitives/sgx/temp-dir/src/lib.rs +++ /dev/null @@ -1,192 +0,0 @@ -//! # temp-dir -//! -//! Copied from the original tempdir crate with tiny adjustments for SGX-compatibility. -//! -//! Note: The temp-dir is deprecated and there might be uncovered security aspects. If we want to -//! use this in production, we should run some checks. - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -use core::sync::atomic::{AtomicU32, Ordering}; -use std::{ - borrow::ToOwned, - collections::hash_map::RandomState, - format, - hash::{BuildHasher, Hasher}, - path::{Path, PathBuf}, - string::String, -}; - -/// Serve some low-security random ID to prevent temp-dir clashes across multiple processes. -fn rand_id() -> String { - // u64 always has more than 4 bytes so this never panics. - format!("{:x}", RandomState::new().build_hasher().finish())[..4].to_owned() -} - -lazy_static::lazy_static! { - /// A unique identifier, which is instanciated upon process start, but it is - /// not the process id itself. - /// - /// This is a workaround for `sgx_tstd` lib not exposing the `process::id()`. - pub static ref PROCESS_UNIQUE_ID: String = rand_id(); -} - -static COUNTER: AtomicU32 = AtomicU32::new(0); - -/// The path of an existing writable directory in a system temporary directory. -/// -/// Drop the struct to delete the directory and everything under it. -/// Deletes symbolic links and does not follow them. -/// -/// Ignores any error while deleting. -/// See [`TempDir::panic_on_cleanup_error`](struct.TempDir.html#method.panic_on_cleanup_error). -/// -/// # Example -/// ```rust -/// use itp_sgx_temp_dir::TempDir; -/// let d = TempDir::new().unwrap(); -/// // Prints "/tmp/t1a9b-0". -/// println!("{:?}", d.path()); -/// let f = d.child("file1"); -/// // Prints "/tmp/t1a9b-0/file1". -/// println!("{:?}", f); -/// std::fs::write(&f, b"abc").unwrap(); -/// assert_eq!( -/// "abc", -/// std::fs::read_to_string(&f).unwrap(), -/// ); -/// // Prints "/tmp/t1a9b-1". -/// println!("{:?}", TempDir::new().unwrap().path()); -/// ``` -#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)] -pub struct TempDir { - path_buf: Option, - panic_on_delete_err: bool, -} -impl TempDir { - fn remove_dir(path: &Path) -> Result<(), std::io::Error> { - match std::fs::remove_dir_all(path) { - Ok(()) => Ok(()), - Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(()), - Err(e) => Err(std::io::Error::new( - e.kind(), - format!("error removing directory and contents {:?}: {}", path, e), - )), - } - } - - /// Create a new empty directory in a system temporary directory. - /// - /// Drop the struct to delete the directory and everything under it. - /// Deletes symbolic links and does not follow them. - /// - /// Ignores any error while deleting. - /// See [`TempDir::panic_on_cleanup_error`](struct.TempDir.html#method.panic_on_cleanup_error). - /// - /// # Errors - /// Returns `Err` when it fails to create the directory. - /// - /// # Example - /// ```rust - /// // Prints "/tmp/t1a9b-0". - /// println!("{:?}", itp_sgx_temp_dir::TempDir::new().unwrap().path()); - /// ``` - pub fn new() -> Result { - // Prefix with 't' to avoid name collisions with `temp-file` crate. - Self::with_prefix("t") - } - - /// Create a new empty directory in a system temporary directory. - /// Use `prefix` as the first part of the directory's name. - /// - /// Drop the struct to delete the directory and everything under it. - /// Deletes symbolic links and does not follow them. - /// - /// Ignores any error while deleting. - /// See [`TempDir::panic_on_cleanup_error`](struct.TempDir.html#method.panic_on_cleanup_error). - /// - /// # Errors - /// Returns `Err` when it fails to create the directory. - /// - /// # Example - /// ```rust - /// // Prints "/tmp/ok1a9b-0". - /// println!("{:?}", itp_sgx_temp_dir::TempDir::with_prefix("ok").unwrap().path()); - /// ``` - pub fn with_prefix(prefix: impl AsRef) -> Result { - let path_buf = std::env::temp_dir().join(format!( - "{}{}-{:x}", - prefix.as_ref(), - // std::process::id(), -> The original tempdir crate had this, but the sgx-std lib does not expose it. - *PROCESS_UNIQUE_ID, - COUNTER.fetch_add(1, Ordering::AcqRel), - )); - std::fs::create_dir(&path_buf).map_err(|e| { - std::io::Error::new( - e.kind(), - format!("error creating directory {:?}: {}", &path_buf, e), - ) - })?; - Ok(Self { path_buf: Some(path_buf), panic_on_delete_err: false }) - } - - /// Remove the directory on its contents now. Do nothing later on drop. - /// - /// # Errors - /// Returns an error if the directory exists and we fail to remove it and its contents. - #[allow(clippy::missing_panics_doc)] - pub fn cleanup(mut self) -> Result<(), std::io::Error> { - Self::remove_dir(&self.path_buf.take().unwrap()) - } - - /// Make the struct panic on Drop if it hits an error while - /// removing the directory or its contents. - #[must_use] - pub fn panic_on_cleanup_error(mut self) -> Self { - Self { path_buf: self.path_buf.take(), panic_on_delete_err: true } - } - - /// Do not delete the directory or its contents. - /// - /// This is useful when debugging a test. - pub fn leak(mut self) { - self.path_buf.take(); - } - - /// The path to the directory. - #[must_use] - #[allow(clippy::missing_panics_doc)] - pub fn path(&self) -> &Path { - self.path_buf.as_ref().unwrap() - } - - /// The path to `name` under the directory. - #[must_use] - #[allow(clippy::missing_panics_doc)] - pub fn child(&self, name: impl AsRef) -> PathBuf { - let mut result = self.path_buf.as_ref().unwrap().clone(); - result.push(name.as_ref()); - result - } -} -impl Drop for TempDir { - fn drop(&mut self) { - if let Some(path) = self.path_buf.take() { - let result = Self::remove_dir(&path); - if self.panic_on_delete_err { - if let Err(e) = result { - panic!("{}", e); - } - } - } - } -} - -#[cfg(test)] -mod test; diff --git a/tee-worker/identity/core-primitives/sgx/temp-dir/src/test.rs b/tee-worker/identity/core-primitives/sgx/temp-dir/src/test.rs deleted file mode 100644 index 8b3ac50c43..0000000000 --- a/tee-worker/identity/core-primitives/sgx/temp-dir/src/test.rs +++ /dev/null @@ -1,231 +0,0 @@ -use crate::{TempDir, COUNTER}; -use core::sync::atomic::Ordering; -use safe_lock::SafeLock; -use std::{io::ErrorKind, path::Path}; - -// The error tests require all tests to run single-threaded. -static LOCK: SafeLock = SafeLock::new(); - -fn make_non_writable(path: &Path) { - assert!(std::process::Command::new("chmod") - .arg("-w") - .arg(path) - .status() - .unwrap() - .success()); -} - -fn make_writable(path: &Path) { - assert!(std::process::Command::new("chmod") - .arg("u+w") - .arg(path) - .status() - .unwrap() - .success()); -} - -fn should_skip_cleanup_test() -> bool { - // On Gitlab's shared CI runners, the cleanup always succeeds and the - // test fails. So we skip these tests when it's running on Gitlab CI. - // if std::env::current_dir().unwrap().starts_with("/builds/") { - // println!("Running on Gitlab CI. Skipping test."); - // return true; - // } - // false - - // The above code was from the original. However, for some reason the - // cleanup always succeeds on my local machine too. I am not sure why - // this is the case. So we skip them always for now. - true -} - -#[test] -fn new() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - println!("{:?}", temp_dir); - println!("{:?}", TempDir::new().unwrap()); - let metadata = std::fs::metadata(temp_dir.path()).unwrap(); - assert!(metadata.is_dir()); - let temp_dir2 = TempDir::new().unwrap(); - assert_ne!(temp_dir.path(), temp_dir2.path()); -} - -#[test] -fn new_error() { - let _guard = LOCK.lock(); - let previous_counter_value = COUNTER.load(Ordering::SeqCst); - let temp_dir = TempDir::new().unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - COUNTER.store(previous_counter_value, Ordering::SeqCst); - let e = TempDir::new().unwrap_err(); - assert_eq!(std::io::ErrorKind::AlreadyExists, e.kind()); - assert!( - e.to_string().starts_with(&format!("error creating directory {:?}: ", dir_path)), - "unexpected error {:?}", - e - ); -} - -#[test] -fn with_prefix() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::with_prefix("prefix1").unwrap(); - let name = temp_dir.path().file_name().unwrap(); - assert!(name.to_str().unwrap().starts_with("prefix1"), "{:?}", temp_dir); - let metadata = std::fs::metadata(temp_dir.path()).unwrap(); - assert!(metadata.is_dir()); - let temp_dir2 = TempDir::new().unwrap(); - assert_ne!(temp_dir.path(), temp_dir2.path()); -} - -#[test] -fn with_prefix_error() { - let _guard = LOCK.lock(); - let previous_counter_value = COUNTER.load(Ordering::SeqCst); - let temp_dir = TempDir::with_prefix("prefix1").unwrap(); - COUNTER.store(previous_counter_value, Ordering::SeqCst); - let e = TempDir::with_prefix("prefix1").unwrap_err(); - assert_eq!(std::io::ErrorKind::AlreadyExists, e.kind()); - assert!( - e.to_string() - .starts_with(&format!("error creating directory {:?}: ", temp_dir.path())), - "unexpected error {:?}", - e - ); -} - -#[test] -fn child() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - let file1_path = temp_dir.child("file1"); - assert!(file1_path.ends_with("file1"), "{:?}", file1_path.to_string_lossy()); - assert!(file1_path.starts_with(temp_dir.path()), "{:?}", file1_path.to_string_lossy()); - std::fs::write(&file1_path, b"abc").unwrap(); -} - -#[test] -fn cleanup() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - std::fs::write(&temp_dir.child("file1"), b"abc").unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - std::fs::metadata(&dir_path).unwrap(); - temp_dir.cleanup().unwrap(); - assert_eq!(ErrorKind::NotFound, std::fs::metadata(&dir_path).unwrap_err().kind()); -} - -#[test] -fn cleanup_already_deleted() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - std::fs::remove_dir_all(temp_dir.path()).unwrap(); - temp_dir.cleanup().unwrap(); -} - -#[cfg(unix)] -#[test] -fn cleanup_error() { - if should_skip_cleanup_test() { - return - } - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - let file1_path = temp_dir.child("file1"); - std::fs::write(&file1_path, b"abc").unwrap(); - make_non_writable(&dir_path); - let result = temp_dir.cleanup(); - std::fs::metadata(&dir_path).unwrap(); - std::fs::metadata(&file1_path).unwrap(); - make_writable(&dir_path); - std::fs::remove_dir_all(&dir_path).unwrap(); - let e = result.unwrap_err(); - assert_eq!(std::io::ErrorKind::PermissionDenied, e.kind()); - assert!( - e.to_string() - .starts_with(&format!("error removing directory and contents {:?}: ", dir_path)), - "unexpected error {:?}", - e - ); -} - -#[test] -fn test_drop() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - let file1_path = temp_dir.child("file1"); - std::fs::write(&file1_path, b"abc").unwrap(); - TempDir::new().unwrap(); - std::fs::metadata(&dir_path).unwrap(); - std::fs::metadata(&file1_path).unwrap(); - drop(temp_dir); - assert_eq!(ErrorKind::NotFound, std::fs::metadata(&dir_path).unwrap_err().kind()); - assert_eq!(ErrorKind::NotFound, std::fs::metadata(&file1_path).unwrap_err().kind()); -} - -#[test] -fn drop_already_deleted() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - std::fs::remove_dir(temp_dir.path()).unwrap(); -} - -#[cfg(unix)] -#[test] -fn drop_error_ignored() { - if should_skip_cleanup_test() { - return - } - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - let file1_path = temp_dir.child("file1"); - std::fs::write(&file1_path, b"abc").unwrap(); - make_non_writable(&dir_path); - drop(temp_dir); - std::fs::metadata(&dir_path).unwrap(); - std::fs::metadata(&file1_path).unwrap(); - make_writable(&dir_path); - std::fs::remove_dir_all(&dir_path).unwrap(); -} - -#[cfg(unix)] -#[test] -fn drop_error_panic() { - if should_skip_cleanup_test() { - return - } - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap().panic_on_cleanup_error(); - let dir_path = temp_dir.path().to_path_buf(); - let file1_path = temp_dir.child("file1"); - std::fs::write(&file1_path, b"abc").unwrap(); - make_non_writable(&dir_path); - let result = std::panic::catch_unwind(move || drop(temp_dir)); - std::fs::metadata(&dir_path).unwrap(); - std::fs::metadata(&file1_path).unwrap(); - make_writable(&dir_path); - std::fs::remove_dir_all(&dir_path).unwrap(); - let msg = result.unwrap_err().downcast::().unwrap(); - assert!( - msg.contains("error removing directory and contents ",), - "unexpected panic message {:?}", - msg - ); -} - -#[test] -fn leak() { - let _guard = LOCK.lock(); - let temp_dir = TempDir::new().unwrap(); - let dir_path = temp_dir.path().to_path_buf(); - let file1_path = temp_dir.child("file1"); - std::fs::write(&file1_path, b"abc").unwrap(); - temp_dir.leak(); - std::fs::metadata(&dir_path).unwrap(); - std::fs::metadata(&file1_path).unwrap(); - std::fs::remove_dir_all(&dir_path).unwrap(); -} diff --git a/tee-worker/identity/core-primitives/stf-executor/Cargo.toml b/tee-worker/identity/core-primitives/stf-executor/Cargo.toml index 7dbb8a8f2b..e77096f69e 100644 --- a/tee-worker/identity/core-primitives/stf-executor/Cargo.toml +++ b/tee-worker/identity/core-primitives/stf-executor/Cargo.toml @@ -1,53 +1,45 @@ [package] -name = "itp-stf-executor" +name = "id-itp-stf-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } +hex = { workspace = true, features = ["alloc"] } -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["untrusted_time"] } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, features = ["untrusted_time"], optional = true } +sgx_types = { workspace = true } -# local dependencies -itp-enclave-metrics = { path = "../enclave-metrics", default-features = false } -itp-node-api = { path = "../node-api", default-features = false } -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../substrate-sgx/externalities" } -itp-stf-interface = { path = "../stf-interface", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-stf-state-observer = { path = "../stf-state-observer", default-features = false } -itp-time-utils = { path = "../time-utils", default-features = false } -itp-top-pool-author = { path = "../top-pool-author", default-features = false } -itp-types = { path = "../types", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-node-api = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-stf-state-observer = { workspace = true } +itp-time-utils = { workspace = true } +itp-types = { workspace = true } -# sgx enabled external libraries -thiserror_sgx = { optional = true, package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../top-pool-author", default-features = false } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } -# substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# dev dependencies -itc-parentchain-test = { path = "../../core/parentchain/test", optional = true, default-features = false } -itp-test = { path = "../test", default-features = false, optional = true } +itc-parentchain-test = { workspace = true, optional = true } +itp-test = { workspace = true, optional = true } [dev-dependencies] -itp-stf-state-observer = { path = "../stf-state-observer", features = ["mocks"] } -itp-stf-interface = { path = "../stf-interface", features = ["mocks"] } -itp-top-pool = { path = "../top-pool", features = ["mocks"] } -itp-test = { path = "../test" } +itp-stf-state-observer = { workspace = true, features = ["std", "mocks"] } +itp-stf-interface = { workspace = true, features = ["std", "mocks"] } +itp-top-pool = { package = "id-itp-top-pool", path = "../top-pool", features = ["mocks"] } +itp-test = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/tee-worker/identity/core-primitives/stf-interface/Cargo.toml b/tee-worker/identity/core-primitives/stf-interface/Cargo.toml deleted file mode 100644 index aadb5baac9..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "itp-stf-interface" -version = "0.8.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } - -itp-node-api-metadata = { path = "../node-api/metadata", default-features = false, features = ["mocks"] } -itp-node-api-metadata-provider = { path = "../node-api/metadata-provider", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-types = { default-features = false, path = "../types" } - -[features] -default = ["std"] -std = [ - "itp-node-api-metadata/std", - "itp-node-api-metadata-provider/std", - "itp-stf-primitives/std", - "itp-types/std", -] -sgx = [] -mocks = [] diff --git a/tee-worker/identity/core-primitives/stf-interface/src/lib.rs b/tee-worker/identity/core-primitives/stf-interface/src/lib.rs deleted file mode 100644 index 179adf6504..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/src/lib.rs +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Provides a state interface. -//! This allow to easily mock the stf and exchange it with another storage. - -#![cfg_attr(not(feature = "std"), no_std)] - -extern crate alloc; - -use alloc::{sync::Arc, vec::Vec}; -use codec::{Decode, Encode}; -use core::fmt::Debug; -use itp_node_api_metadata::NodeMetadataTrait; -use itp_node_api_metadata_provider::AccessNodeMetadata; -use itp_stf_primitives::traits::TrustedCallVerification; -use itp_types::{ - parentchain::{BlockHash, BlockNumber, ParentchainCall, ParentchainId}, - ShardIdentifier, H256, -}; - -#[cfg(feature = "mocks")] -pub mod mocks; -pub mod parentchain_pallet; -pub mod runtime_upgrade; -pub mod sudo_pallet; -pub mod system_pallet; - -pub const SHARD_CREATION_HEADER_KEY: &str = "ShardCreationHeaderKey"; - -/// Interface to initialize a new state. -pub trait InitState { - /// Initialize a new state for a given enclave account. - fn init_state(enclave_account: AccountId) -> State; -} - -/// Interface to query shard creation block information for shard on a specified parentchain -pub trait ShardCreationQuery { - fn get_shard_creation_info(state: &mut S) -> ShardCreationInfo; -} - -/// Interface for all functions calls necessary to update an already -/// initialized state. -pub trait UpdateState { - /// Updates a given state for - fn apply_state_diff(state: &mut State, state_diff: StateDiff); - fn storage_hashes_to_update_on_block(parentchain_id: &ParentchainId) -> Vec>; -} - -/// Interface to execute state mutating calls on a state. -pub trait StateCallInterface -where - NodeMetadataRepository: AccessNodeMetadata, - NodeMetadataRepository::MetadataType: NodeMetadataTrait, - TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, -{ - type Error: Encode; - type Result: StfExecutionResult; - - /// Execute a call on a specific state. Callbacks are added as an `OpaqueCall`. - /// - /// Litentry: - /// 1. add a parameter to pass the top_hash around - /// 2. returns the encoded rpc response value field that should be passed - /// back to the requester when the call is triggered synchronously - fn execute_call( - state: &mut State, - shard: &ShardIdentifier, - call: TCS, - top_hash: H256, - calls: &mut Vec, - node_metadata_repo: Arc, - ) -> Result; -} - -/// Interface to execute state reading getters on a state. -pub trait StateGetterInterface { - /// Execute a getter on a specific state. - fn execute_getter(state: &mut S, getter: G) -> Option>; -} - -/// Trait used to abstract the call execution. -pub trait ExecuteCall -where - NodeMetadataRepository: AccessNodeMetadata, - NodeMetadataRepository::MetadataType: NodeMetadataTrait, -{ - type Error: Encode; - type Result: StfExecutionResult; - - /// Execute a call. Callbacks are added as an `OpaqueCall`. - /// - /// Litentry: returns the encoded rpc response that should be passed back to - /// the requester when the call is triggered synchronously - fn execute( - self, - shard: &ShardIdentifier, - top_hash: H256, - calls: &mut Vec, - node_metadata_repo: Arc, - ) -> Result; - - /// Get storages hashes that should be updated for a specific call. - fn get_storage_hashes_to_update(self) -> Vec>; -} - -/// Trait used to abstract the getter execution. -pub trait ExecuteGetter { - /// Execute a getter. - fn execute(self) -> Option>; - /// Get storages hashes that should be updated for a specific getter. - fn get_storage_hashes_to_update(self) -> Vec>; -} - -pub trait StfExecutionResult { - fn get_encoded_result(self) -> Vec; - fn force_connection_wait(&self) -> bool; -} - -impl StfExecutionResult for () { - fn get_encoded_result(self) -> Vec { - Vec::default() - } - fn force_connection_wait(&self) -> bool { - false - } -} - -#[derive(Debug, Clone, Copy, Encode, Decode)] -pub struct BlockMetadata { - pub number: BlockNumber, - pub hash: BlockHash, - // Litentry: we don't seem to need the timestamp -} - -#[derive(Debug, Clone, Copy, Encode, Decode)] -pub struct ShardCreationInfo { - pub litentry: Option, - pub target_a: Option, - pub target_b: Option, -} - -impl ShardCreationInfo { - pub fn for_parentchain(&self, id: ParentchainId) -> Option { - match id { - ParentchainId::Litentry => self.litentry, - ParentchainId::TargetA => self.target_a, - ParentchainId::TargetB => self.target_b, - } - } -} diff --git a/tee-worker/identity/core-primitives/stf-interface/src/mocks.rs b/tee-worker/identity/core-primitives/stf-interface/src/mocks.rs deleted file mode 100644 index 44bda77d36..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/src/mocks.rs +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Provides a mock which implements all traits within this crate. - -extern crate alloc; -use crate::{ - system_pallet::SystemPalletAccountInterface, ExecuteCall, ExecuteGetter, InitState, - StateCallInterface, StateGetterInterface, UpdateState, -}; -use alloc::{string::String, sync::Arc, vec::Vec}; -use codec::{Decode, Encode}; -use core::{fmt::Debug, marker::PhantomData}; -use itp_node_api_metadata::metadata_mocks::NodeMetadataMock; -use itp_node_api_metadata_provider::NodeMetadataRepository; -use itp_stf_primitives::traits::TrustedCallVerification; -use itp_types::{ - parentchain::{ParentchainCall, ParentchainId}, - AccountId, Index, ShardIdentifier, H256, -}; - -#[derive(Default)] -pub struct StateInterfaceMock { - _phantom: PhantomData<(State, StateDiff)>, -} - -impl InitState - for StateInterfaceMock -{ - fn init_state(_enclave_account: AccountId) -> State { - unimplemented!() - } -} - -impl UpdateState for StateInterfaceMock { - fn apply_state_diff(_state: &mut State, _state_diff: StateDiff) { - unimplemented!() - } - - fn storage_hashes_to_update_on_block(_: &ParentchainId) -> Vec> { - unimplemented!() - } -} - -impl StateCallInterface> - for StateInterfaceMock -where - TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, -{ - type Error = String; - type Result = (); - - fn execute_call( - _state: &mut State, - _shard: &ShardIdentifier, - _call: TCS, - _top_hash: H256, - _calls: &mut Vec, - _node_metadata_repo: Arc>, - ) -> Result { - unimplemented!() - } -} - -impl StateGetterInterface - for StateInterfaceMock -{ - fn execute_getter(_state: &mut State, _getter: Getter) -> Option> { - None - } -} - -impl SystemPalletAccountInterface - for StateInterfaceMock -{ - type AccountData = String; - type Index = Index; - - fn get_account_nonce(_state: &mut State, _account_id: &AccountId) -> Self::Index { - unimplemented!() - } - fn get_account_data(_state: &mut State, _account_id: &AccountId) -> Self::AccountData { - unimplemented!() - } -} - -pub struct CallExecutorMock; - -impl ExecuteCall> for CallExecutorMock { - type Error = String; - type Result = (); - - fn execute( - self, - _shard: &ShardIdentifier, - _top_hash: H256, - _calls: &mut Vec, - _node_metadata_repo: Arc>, - ) -> Result<(), Self::Error> { - unimplemented!() - } - - fn get_storage_hashes_to_update(self) -> Vec> { - unimplemented!() - } -} - -pub struct GetterExecutorMock; - -impl ExecuteGetter for GetterExecutorMock { - fn execute(self) -> Option> { - unimplemented!() - } - - fn get_storage_hashes_to_update(self) -> Vec> { - unimplemented!() - } -} diff --git a/tee-worker/identity/core-primitives/stf-interface/src/parentchain_pallet.rs b/tee-worker/identity/core-primitives/stf-interface/src/parentchain_pallet.rs deleted file mode 100644 index a7e05178f0..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/src/parentchain_pallet.rs +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 itp_types::parentchain::ParentchainId; - -/// Interface trait of the parentchain pallet. -pub trait ParentchainPalletInstancesInterface { - type Error; - - /// Updates the block number, block hash and parent hash of the parentchain block. - fn update_parentchain_litentry_block( - state: &mut State, - header: ParentchainHeader, - ) -> Result<(), Self::Error>; - - /// Updates the block number, block hash and parent hash of the parentchain block. - fn update_parentchain_target_a_block( - state: &mut State, - header: ParentchainHeader, - ) -> Result<(), Self::Error>; - - /// Updates the block number, block hash and parent hash of the parentchain block. - fn update_parentchain_target_b_block( - state: &mut State, - header: ParentchainHeader, - ) -> Result<(), Self::Error>; - - fn set_creation_block( - state: &mut State, - header: ParentchainHeader, - parentchain_id: ParentchainId, - ) -> Result<(), Self::Error>; -} diff --git a/tee-worker/identity/core-primitives/stf-interface/src/sudo_pallet.rs b/tee-worker/identity/core-primitives/stf-interface/src/sudo_pallet.rs deleted file mode 100644 index afd2ed1dec..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/src/sudo_pallet.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -/// Interface trait of the sudo pallet. -pub trait SudoPalletInterface { - type AccountId; - - /// Get the root account for a given state. - fn get_root(state: &mut State) -> Self::AccountId; - - /// Get the enclave account for a given state. - fn get_enclave_account(state: &mut State) -> Self::AccountId; -} diff --git a/tee-worker/identity/core-primitives/stf-interface/src/system_pallet.rs b/tee-worker/identity/core-primitives/stf-interface/src/system_pallet.rs deleted file mode 100644 index 82166e846e..0000000000 --- a/tee-worker/identity/core-primitives/stf-interface/src/system_pallet.rs +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 alloc; -use alloc::{boxed::Box, vec::Vec}; - -/// Interface trait of the system pallet for account specific data. -pub trait SystemPalletAccountInterface { - type Index; - type AccountData; - - /// Get the nonce for a given account and state. - fn get_account_nonce(state: &mut State, account_id: &AccountId) -> Self::Index; - - /// Get the account date for a given account and state. - fn get_account_data(state: &mut State, account: &AccountId) -> Self::AccountData; -} - -/// Interface trait of the system pallet for event specific interactions. -pub trait SystemPalletEventInterface { - type EventRecord; - type EventIndex; - type BlockNumber; - type Hash; - - /// Get a Vec of bounded events. - fn get_events(state: &mut State) -> Vec>; - - /// Get the count of the currently stored events. - fn get_event_count(state: &mut State) -> Self::EventIndex; - - /// Get the event topics - fn get_event_topics( - state: &mut State, - topic: &Self::Hash, - ) -> Vec<(Self::BlockNumber, Self::EventIndex)>; - - /// Reset everything event related. - fn reset_events(state: &mut State); -} diff --git a/tee-worker/identity/core-primitives/stf-primitives/Cargo.toml b/tee-worker/identity/core-primitives/stf-primitives/Cargo.toml deleted file mode 100644 index b127b2bc1d..0000000000 --- a/tee-worker/identity/core-primitives/stf-primitives/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "itp-stf-primitives" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" } -derive_more = { version = "0.99.5" } -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - # crates.io - "codec/std", - # substrate - "sp-core/std", - "sp-std/std", - "sp-runtime/std", - "itp-sgx-runtime-primitives/std", - # litentry - "litentry-primitives/std", -] diff --git a/tee-worker/identity/core-primitives/stf-primitives/src/lib.rs b/tee-worker/identity/core-primitives/stf-primitives/src/lib.rs deleted file mode 100644 index 8e5ce6b1c0..0000000000 --- a/tee-worker/identity/core-primitives/stf-primitives/src/lib.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] -extern crate alloc; - -pub mod error; -pub mod traits; -pub mod types; diff --git a/tee-worker/identity/core-primitives/stf-primitives/src/types.rs b/tee-worker/identity/core-primitives/stf-primitives/src/types.rs deleted file mode 100644 index a96da4087c..0000000000 --- a/tee-worker/identity/core-primitives/stf-primitives/src/types.rs +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 alloc; -use crate::traits::{PoolTransactionValidation, TrustedCallVerification}; -use alloc::boxed::Box; -use codec::{Compact, Decode, Encode}; -use core::fmt::Debug; -use litentry_primitives::LitentryMultiSignature; -use sp_core::{blake2_256, crypto::AccountId32, ed25519, sr25519, Pair, H256}; -use sp_runtime::{ - traits::Verify, - transaction_validity::{TransactionValidityError, ValidTransaction}, - MultiSignature, -}; -use sp_std::{vec, vec::Vec}; - -pub type Signature = MultiSignature; -pub type AuthorityId = ::Signer; -pub type AccountId = AccountId32; -pub type Nonce = u32; -pub type Hash = H256; -pub type BalanceTransferFn = ([u8; 2], AccountId, Compact); -pub type ShardIdentifier = H256; - -#[derive(Clone)] -pub enum KeyPair { - Sr25519(Box), - Ed25519(Box), -} - -impl KeyPair { - pub fn sign(&self, payload: &[u8]) -> LitentryMultiSignature { - match self { - Self::Sr25519(pair) => pair.sign(payload).into(), - Self::Ed25519(pair) => pair.sign(payload).into(), - } - } - pub fn account_id(&self) -> AccountId { - match self { - Self::Sr25519(pair) => pair.public().into(), - Self::Ed25519(pair) => pair.public().into(), - } - } -} - -impl From for KeyPair { - fn from(x: ed25519::Pair) -> Self { - KeyPair::Ed25519(Box::new(x)) - } -} - -impl From for KeyPair { - fn from(x: sr25519::Pair) -> Self { - KeyPair::Sr25519(Box::new(x)) - } -} - -#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum TrustedOperation -where - TCS: PartialEq + Encode + Debug, - G: PartialEq + Encode + Debug, -{ - #[codec(index = 0)] - indirect_call(TCS), - #[codec(index = 1)] - direct_call(TCS), - #[codec(index = 2)] - get(G), -} - -impl From for TrustedOperation -where - TCS: PartialEq + Encode + Debug, - G: PartialEq + Encode + Debug, -{ - fn from(item: G) -> Self { - TrustedOperation::get(item) - } -} - -impl TrustedOperation -where - TCS: PartialEq + TrustedCallVerification + Encode + Debug, - G: PartialEq + Encode + Debug, -{ - pub fn to_call(&self) -> Option<&TCS> { - match self { - TrustedOperation::direct_call(c) => Some(c), - TrustedOperation::indirect_call(c) => Some(c), - _ => None, - } - } - - pub fn signed_caller_account(&self) -> Option { - match self { - TrustedOperation::direct_call(c) => c.sender_identity().to_account_id(), - TrustedOperation::indirect_call(c) => c.sender_identity().to_account_id(), - _ => None, - } - } - - fn validate_trusted_call(trusted_call_signed: &TCS) -> ValidTransaction { - let from = trusted_call_signed.sender_identity(); - let requires = vec![]; - let provides = vec![(from, trusted_call_signed.nonce()).encode()]; - - ValidTransaction { priority: 1 << 20, requires, provides, longevity: 64, propagate: true } - } - - pub fn hash(&self) -> H256 { - blake2_256(&self.encode()).into() - } -} - -impl PoolTransactionValidation for TrustedOperation -where - TCS: PartialEq + TrustedCallVerification + Encode + Debug, - G: PartialEq + Encode + PoolTransactionValidation + Debug, -{ - fn validate(&self) -> Result { - match self { - TrustedOperation::direct_call(trusted_call_signed) => - Ok(Self::validate_trusted_call(trusted_call_signed)), - TrustedOperation::indirect_call(trusted_call_signed) => - Ok(Self::validate_trusted_call(trusted_call_signed)), - TrustedOperation::get(getter) => getter.validate(), - } - } -} - -/// Trusted operation Or hash -/// -/// Allows to refer to trusted calls either by its raw representation or its hash. -#[derive(Clone, Debug, Encode, Decode, PartialEq)] -pub enum TrustedOperationOrHash -where - TCS: PartialEq + Encode + Debug + Send + Sync, - G: PartialEq + Encode + Debug + Send + Sync, -{ - /// The hash of the call. - #[codec(index = 0)] - Hash(H256), - /// Raw extrinsic bytes. - #[codec(index = 1)] - OperationEncoded(Vec), - /// Raw extrinsic - #[codec(index = 2)] - Operation(Box>), -} - -impl TrustedOperationOrHash -where - TCS: PartialEq + Encode + Debug + Send + Sync, - G: PartialEq + Encode + Debug + Send + Sync, -{ - pub fn from_top(top: TrustedOperation) -> Self { - TrustedOperationOrHash::Operation(Box::new(top)) - } -} - -/// Payload to be sent to peers for a state update. -#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode)] -pub struct StatePayload { - /// State hash before the `state_update` was applied. - state_hash_apriori: H256, - /// State hash after the `state_update` was applied. - state_hash_aposteriori: H256, - /// State diff applied to state with hash `state_hash_apriori` - /// leading to state with hash `state_hash_aposteriori`. - state_update: StateUpdate, -} - -impl StatePayload { - /// Get state hash before the `state_update` was applied. - pub fn state_hash_apriori(&self) -> H256 { - self.state_hash_apriori - } - /// Get state hash after the `state_update` was applied. - pub fn state_hash_aposteriori(&self) -> H256 { - self.state_hash_aposteriori - } - /// Reference to the `state_update`. - pub fn state_update(&self) -> &StateUpdate { - &self.state_update - } - - /// Create new `StatePayload` instance. - pub fn new(apriori: H256, aposteriori: H256, update: StateUpdate) -> Self { - Self { - state_hash_apriori: apriori, - state_hash_aposteriori: aposteriori, - state_update: update, - } - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/Cargo.toml b/tee-worker/identity/core-primitives/stf-state-handler/Cargo.toml deleted file mode 100644 index 898f85423c..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/Cargo.toml +++ /dev/null @@ -1,72 +0,0 @@ -[package] -name = "itp-stf-state-handler" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# local dependencies -itp-hashing = { path = "../../core-primitives/hashing", default-features = false } -itp-settings = { path = "../../core-primitives/settings" } -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../../core-primitives/substrate-sgx/externalities" } -itp-sgx-io = { path = "../../core-primitives/sgx/io", default-features = false } -itp-stf-interface = { default-features = false, path = "../../core-primitives/stf-interface" } -itp-stf-state-observer = { path = "../stf-state-observer", default-features = false } -itp-time-utils = { path = "../../core-primitives/time-utils", default-features = false } -itp-types = { path = "../types", default-features = false } - -# for tests -itp-sgx-temp-dir = { version = "0.1", default-features = false, optional = true, path = "../../core-primitives/sgx/temp-dir" } - -# sgx enabled external libraries -rust-base58_sgx = { package = "rust-base58", rev = "sgx_1.1.3", git = "https://github.com/mesalock-linux/rust-base58-sgx", optional = true, default-features = false, features = ["mesalock_sgx"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -rust-base58 = { package = "rust-base58", version = "0.0.4", optional = true } -thiserror = { version = "1.0", optional = true } - -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[dev-dependencies] -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-state-observer = { path = "../stf-state-observer", features = ["mocks"] } -itp-hashing = { path = "../../core-primitives/hashing", features = ["std"] } - -[features] -default = ["std"] -std = [ - "rust-base58", - "itp-sgx-crypto/std", - "itp-sgx-externalities/std", - "itp-sgx-io/std", - "itp-stf-interface/std", - "itp-stf-state-observer/std", - "itp-time-utils/std", - "itp-types/std", - "thiserror", - "log/std", -] -sgx = [ - "sgx_tstd", - "rust-base58_sgx", - "itp-sgx-crypto/sgx", - "itp-sgx-externalities/sgx", - "itp-sgx-io/sgx", - "itp-stf-state-observer/sgx", - "itp-time-utils/sgx", - "thiserror_sgx", -] -test = [ - "itp-sgx-crypto/mocks", - "itp-stf-interface/mocks", - "itp-sgx-temp-dir", -] diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/error.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/error.rs deleted file mode 100644 index e283c657a8..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/error.rs +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -#[cfg(feature = "std")] -use rust_base58::base58::FromBase58Error; - -#[cfg(feature = "sgx")] -use base58::FromBase58Error; - -use crate::state_snapshot_primitives::StateId; -use itp_types::ShardIdentifier; -use sgx_types::sgx_status_t; -use std::{boxed::Box, format, string::String}; - -pub type Result = core::result::Result; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Empty state repository")] - EmptyRepository, - #[error("State ID is invalid and does not exist: {0}")] - InvalidStateId(StateId), - #[error("Shard is invalid and does not exist: {0}")] - InvalidShard(ShardIdentifier), - #[error("State with hash {0} could not be found in the state repository")] - StateNotFoundInRepository(String), - #[error("State observer error: {0}")] - StateObserver(#[from] itp_stf_state_observer::error::Error), - #[error("Cache size for registry is zero")] - ZeroCacheSize, - #[error("Could not acquire lock, lock is poisoned")] - LockPoisoning, - #[error("OsString conversion error")] - OsStringConversion, - #[error("SGX crypto error: {0}")] - CryptoError(itp_sgx_crypto::Error), - #[error("IO error: {0}")] - IO(std::io::Error), - #[error("SGX error, status: {0}")] - SgxError(sgx_status_t), - #[error(transparent)] - Other(#[from] Box), -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Self::IO(e) - } -} - -impl From for Error { - fn from(e: codec::Error) -> Self { - Self::Other(format!("{:?}", e).into()) - } -} - -impl From for Error { - fn from(sgx_status: sgx_status_t) -> Self { - Self::SgxError(sgx_status) - } -} - -impl From for Error { - fn from(crypto_error: itp_sgx_crypto::Error) -> Self { - Self::CryptoError(crypto_error) - } -} - -impl From for Error { - fn from(e: FromBase58Error) -> Self { - Self::Other(format!("{:?}", e).into()) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/lib.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/lib.rs deleted file mode 100644 index 4b6235f9c0..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/lib.rs +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] -#![feature(assert_matches)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use rust_base58_sgx as base58; - pub use thiserror_sgx as thiserror; -} - -pub mod error; -pub mod file_io; -pub mod handle_state; -pub mod in_memory_state_file_io; -pub mod query_shard_state; -pub mod state_handler; -pub mod state_initializer; -mod state_snapshot_primitives; -pub mod state_snapshot_repository; -pub mod state_snapshot_repository_loader; -pub mod test; - -pub use state_handler::StateHandler; diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/query_shard_state.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/query_shard_state.rs deleted file mode 100644 index 11ff46d044..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/query_shard_state.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::error::Result; -use itp_types::ShardIdentifier; -use std::vec::Vec; - -/// Trait for querying shard information on the state -/// -/// The reason this is a separate trait, is that it does not require any -/// SGX exclusive data structures (feature sgx) -pub trait QueryShardState { - /// Query whether a given shard exists - fn shard_exists(&self, shard: &ShardIdentifier) -> Result; - - /// List all available shards - fn list_shards(&self) -> Result>; -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/state_initializer.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/state_initializer.rs deleted file mode 100644 index 5799c20823..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/state_initializer.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::error::Result; -use core::marker::PhantomData; -use itp_sgx_crypto::{ed25519_derivation::DeriveEd25519, key_repository::AccessKey}; -use itp_stf_interface::InitState; -use itp_types::AccountId; -use sp_core::Pair; -use std::sync::Arc; - -/// Create and initialize a new state instance. -pub trait InitializeState { - type StateType; - - fn initialize(&self) -> Result; -} - -pub struct StateInitializer { - shielding_key_repository: Arc, - _phantom: PhantomData<(State, Stf)>, -} - -impl StateInitializer -where - Stf: InitState, - ShieldingKeyRepository: AccessKey, - ShieldingKeyRepository::KeyType: DeriveEd25519, -{ - pub fn new(shielding_key_repository: Arc) -> Self { - Self { shielding_key_repository, _phantom: Default::default() } - } -} - -impl InitializeState - for StateInitializer -where - Stf: InitState, - ShieldingKeyRepository: AccessKey, - ShieldingKeyRepository::KeyType: DeriveEd25519, -{ - type StateType = State; - - fn initialize(&self) -> Result { - // This implementation basically exists because it is non-trivial to initialize the state with - // an enclave account that is derived from the shielding key. - let enclave_account = self.shielding_key_repository.retrieve_key()?.derive_ed25519()?; - Ok(Stf::init_state(enclave_account.public().into())) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs deleted file mode 100644 index 50c3f00afc..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_primitives.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, file_io::StateFileIo}; -use itp_time_utils::now_as_nanos; -use itp_types::ShardIdentifier; -use std::collections::{HashMap, VecDeque}; - -pub type StateId = u128; - -pub(crate) type SnapshotHistory = - HashMap>>; - -/// Internal wrapper for a state hash and state ID. -#[derive(Clone)] -pub(crate) struct StateSnapshotMetaData { - pub(crate) state_hash: HashType, - pub(crate) state_id: StateId, -} - -impl StateSnapshotMetaData { - pub fn new(state_hash: HashType, state_id: StateId) -> Self { - StateSnapshotMetaData { state_hash, state_id } - } -} - -pub(crate) fn initialize_shard_with_snapshot( - shard_identifier: &ShardIdentifier, - file_io: &FileIo, - state: &FileIo::StateType, -) -> Result> -where - FileIo: StateFileIo, -{ - let state_id = generate_current_timestamp_state_id(); - let state_hash = file_io.initialize_shard(shard_identifier, state_id, state)?; - Ok(StateSnapshotMetaData::new(state_hash, state_id)) -} - -pub(crate) fn generate_current_timestamp_state_id() -> StateId { - now_as_nanos() -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs deleted file mode 100644 index 88682efd74..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/state_snapshot_repository_loader.rs +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::Result, - file_io::StateFileIo, - state_initializer::InitializeState, - state_snapshot_primitives::{ - initialize_shard_with_snapshot, SnapshotHistory, StateId, StateSnapshotMetaData, - }, - state_snapshot_repository::StateSnapshotRepository, -}; -use itp_hashing::Hash; -use itp_types::ShardIdentifier; -use log::*; -use std::{collections::VecDeque, fmt::Debug, iter::FromIterator, sync::Arc, vec::Vec}; - -/// Loads a state snapshot repository from existing shards directory with state files. -pub struct StateSnapshotRepositoryLoader { - file_io: Arc, - state_initializer: Arc, -} - -impl StateSnapshotRepositoryLoader -where - FileIo: StateFileIo, - ::HashType: Copy + Eq + Debug, - ::StateType: Clone + Hash, - StateInitializer: InitializeState, -{ - pub fn new(file_io: Arc, state_initializer: Arc) -> Self { - Self { file_io, state_initializer } - } - - /// Load a state snapshot repository from an existing set of files and directories. - pub fn load_snapshot_repository( - &self, - snapshot_history_cache_size: usize, - ) -> Result> { - let snapshot_history = self.load_and_initialize_state_snapshot_history()?; - - StateSnapshotRepository::new( - self.file_io.clone(), - snapshot_history_cache_size, - snapshot_history, - ) - } - - fn load_and_initialize_state_snapshot_history( - &self, - ) -> Result> { - let mut repository = SnapshotHistory::new(); - - let shards = self.file_io.list_shards()?; - debug!("Found {} shard(s) to load state from", shards.len()); - - for shard in shards { - let mut state_ids = self.file_io.list_state_ids_for_shard(&shard)?; - // Sort by id (which are timestamp), highest, i.e. newest, first - state_ids.sort_unstable(); - state_ids.reverse(); - - let mut snapshot_metadata: Vec<_> = self.map_to_snapshot_metadata(&shard, state_ids); - - if snapshot_metadata.is_empty() { - warn!( - "No (valid) states found for shard {:?}, initializing empty shard state", - shard - ); - let initial_state = self.state_initializer.initialize()?; - let initial_snapshot_metadata = - initialize_shard_with_snapshot(&shard, self.file_io.as_ref(), &initial_state)?; - snapshot_metadata.push(initial_snapshot_metadata); - } else { - debug!( - "Found {} state snapshot(s) for shard {}, latest snapshot is {}", - snapshot_metadata.len(), - &shard, - snapshot_metadata.first().map(|f| f.state_id).unwrap_or_default() - ); - } - - let snapshot_history = VecDeque::from_iter(snapshot_metadata); - - repository.insert(shard, snapshot_history); - } - Ok(repository) - } - - fn map_to_snapshot_metadata( - &self, - shard: &ShardIdentifier, - state_ids: Vec, - ) -> Vec> { - state_ids - .into_iter() - .flat_map(|state_id| match self.file_io.compute_hash(shard, state_id) { - Ok(hash) => Some(StateSnapshotMetaData::new(hash, state_id)), - Err(e) => { - warn!( - "Failed to compute hash for state snapshot with id {}: {:?}, ignoring snapshot as a result", - state_id, e - ); - None - }, - }) - .collect() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - in_memory_state_file_io::InMemoryStateFileIo, - test::mocks::initialize_state_mock::InitializeStateMock, - }; - use codec::Encode; - use itp_types::H256; - use sp_core::blake2_256; - - #[derive(Encode, Clone, Default, Copy)] - struct TestState(pub u64); - - type TestStateHash = H256; - type TestFileIo = InMemoryStateFileIo; - type TestStateInitializer = InitializeStateMock; - type TestLoader = StateSnapshotRepositoryLoader; - - impl Hash for TestState { - fn hash(&self) -> TestStateHash { - blake2_256(&self.encode()).into() - } - } - - #[test] - fn loading_from_empty_shard_directories_initializes_files() { - let shards = - vec![ShardIdentifier::random(), ShardIdentifier::random(), ShardIdentifier::random()]; - let (_, loader) = create_test_fixtures(shards.as_slice()); - - let snapshot_history = loader.load_and_initialize_state_snapshot_history().unwrap(); - assert_eq!(shards.len(), snapshot_history.len()); - for snapshots in snapshot_history.values() { - assert_eq!(1, snapshots.len()); - } - } - - #[test] - fn loading_without_shards_returns_empty_directory() { - let (_, loader) = create_test_fixtures(&[]); - - let snapshot_history = loader.load_and_initialize_state_snapshot_history().unwrap(); - assert!(snapshot_history.is_empty()); - } - - #[test] - fn loading_from_files_orders_by_timestamp() { - let shards = - vec![ShardIdentifier::random(), ShardIdentifier::random(), ShardIdentifier::random()]; - let (file_io, loader) = create_test_fixtures(shards.as_slice()); - - add_state_snapshots( - file_io.as_ref(), - &shards[0], - &[1_000_000, 2_000_000, 3_000_000, 4_000_000], - ); - add_state_snapshots(file_io.as_ref(), &shards[1], &[10_000_000, 9_000_000]); - add_state_snapshots(file_io.as_ref(), &shards[2], &[14_000_000, 11_000_000, 12_000_000]); - - let snapshot_history = loader.load_and_initialize_state_snapshot_history().unwrap(); - - assert_eq!(shards.len(), snapshot_history.len()); - assert_latest_state_id(&snapshot_history, &shards[0], 4_000_000); - assert_latest_state_id(&snapshot_history, &shards[1], 10_000_000); - assert_latest_state_id(&snapshot_history, &shards[2], 14_000_000); - } - - fn add_state_snapshots(file_io: &TestFileIo, shard: &ShardIdentifier, state_ids: &[StateId]) { - for state_id in state_ids { - add_snapshot_with_state_ids(file_io, shard, *state_id); - } - } - - fn add_snapshot_with_state_ids( - file_io: &TestFileIo, - shard: &ShardIdentifier, - state_id: StateId, - ) { - file_io.initialize_shard(shard, state_id, &Default::default()).unwrap(); - } - - fn assert_latest_state_id( - snapshot_history: &SnapshotHistory, - shard: &ShardIdentifier, - state_id: StateId, - ) { - assert_eq!(snapshot_history.get(shard).unwrap().front().unwrap().state_id, state_id) - } - - fn create_test_fixtures(shards: &[ShardIdentifier]) -> (Arc, TestLoader) { - let file_io = Arc::new(TestFileIo::new(shards, Box::new(|x| *x), Box::new(|x| x))); - let state_initializer = Arc::new(TestStateInitializer::new(Default::default())); - let loader = StateSnapshotRepositoryLoader::new(file_io.clone(), state_initializer); - (file_io, loader) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs deleted file mode 100644 index 32ed41e671..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/initialize_state_mock.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Result, state_initializer::InitializeState}; -use std::marker::PhantomData; - -/// Initialize state mock. -pub struct InitializeStateMock { - init_state: State, - _phantom: PhantomData, -} - -impl InitializeStateMock { - pub fn new(init_state: State) -> Self { - Self { init_state, _phantom: Default::default() } - } -} - -impl InitializeState for InitializeStateMock -where - State: Clone, -{ - type StateType = State; - - fn initialize(&self) -> Result { - Ok(self.init_state.clone()) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/mod.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/mod.rs deleted file mode 100644 index 4a6fcfae26..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod initialize_state_mock; -pub mod state_key_repository_mock; -pub mod versioned_state_access_mock; diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs deleted file mode 100644 index 443877083d..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mocks/state_key_repository_mock.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use itp_sgx_crypto::{ - error::Result, - key_repository::{AccessKey, MutateKey}, - StateCrypto, -}; - -#[derive(Default)] -pub struct StateKeyRepositoryMock -where - KeyType: StateCrypto + Clone + Default, -{ - key: RwLock, -} - -impl StateKeyRepositoryMock -where - KeyType: StateCrypto + Clone + Default, -{ - #[cfg(all(feature = "test", feature = "sgx"))] - pub fn new(key: KeyType) -> Self { - StateKeyRepositoryMock { key: RwLock::new(key) } - } -} - -impl AccessKey for StateKeyRepositoryMock -where - KeyType: StateCrypto + Clone + Default, -{ - type KeyType = KeyType; - - fn retrieve_key(&self) -> Result { - Ok(self.key.read().unwrap().clone()) - } -} - -impl MutateKey for StateKeyRepositoryMock -where - KeyType: StateCrypto + Clone + Default, -{ - fn update_key(&self, key: KeyType) -> Result<()> { - let mut lock = self.key.write().unwrap(); - *lock = key; - Ok(()) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mod.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/test/mod.rs deleted file mode 100644 index e3552cd37f..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/test/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(test)] -pub(crate) mod mocks; - -#[cfg(all(feature = "test", feature = "sgx"))] -pub mod mocks; - -#[cfg(all(feature = "test", feature = "sgx"))] -pub mod sgx_tests; diff --git a/tee-worker/identity/core-primitives/stf-state-handler/src/test/sgx_tests.rs b/tee-worker/identity/core-primitives/stf-state-handler/src/test/sgx_tests.rs deleted file mode 100644 index eef2da2b28..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-handler/src/test/sgx_tests.rs +++ /dev/null @@ -1,360 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - file_io::{sgx::SgxStateFileIo, StateDir, StateFileIo}, - handle_state::HandleState, - in_memory_state_file_io::sgx::create_in_memory_state_io_from_shards_directories, - query_shard_state::QueryShardState, - state_handler::StateHandler, - state_snapshot_repository::{StateSnapshotRepository, VersionedStateAccess}, - state_snapshot_repository_loader::StateSnapshotRepositoryLoader, - test::mocks::initialize_state_mock::InitializeStateMock, -}; -use codec::{Decode, Encode}; -use itp_hashing::Hash; -use itp_sgx_crypto::{ - get_aes_repository, - key_repository::{AccessKey, KeyRepository}, - Aes, AesSeal, StateCrypto, -}; -use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesTrait, SgxExternalitiesType}; -use itp_sgx_io::write; -use itp_sgx_temp_dir::TempDir; -use itp_stf_state_observer::state_observer::StateObserver; -use itp_types::{ShardIdentifier, H256}; -use std::{sync::Arc, thread, vec::Vec}; - -const STATE_SNAPSHOTS_CACHE_SIZE: usize = 3; - -type StateKeyRepository = KeyRepository; -type TestStateInitializer = InitializeStateMock; -type TestStateFileIo = SgxStateFileIo; -type TestStateRepository = StateSnapshotRepository; -type TestStateRepositoryLoader = - StateSnapshotRepositoryLoader; -type TestStateObserver = StateObserver; -type TestStateHandler = StateHandler; - -// Fixme: Move this test to sgx-runtime: -// -// https://github.com/integritee-network/sgx-runtime/issues/23 -pub fn test_sgx_state_decode_encode_works() { - // given - let state = given_hello_world_state(); - - // when - let encoded_state = state.state.encode(); - let state2 = SgxExternalitiesType::decode(&mut encoded_state.as_slice()).unwrap(); - - // then - assert_eq!(state.state, state2); -} - -pub fn test_encrypt_decrypt_state_type_works() { - // given - let state = given_hello_world_state(); - let temp_dir = TempDir::with_prefix("test_encrypt_decrypt_state_type_works").unwrap(); - let state_key = get_aes_repository(temp_dir.path().to_path_buf()) - .unwrap() - .retrieve_key() - .unwrap(); - - // when - let mut state_buffer = state.state.encode(); - state_key.encrypt(&mut state_buffer).unwrap(); - - state_key.decrypt(&mut state_buffer).unwrap(); - let decoded = SgxExternalitiesType::decode(&mut state_buffer.as_slice()).unwrap(); - - // then - assert_eq!(state.state, decoded); -} - -pub fn test_write_and_load_state_works() { - // given - let shard: ShardIdentifier = [94u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_write_and_load_state_works", &shard); - - let state_handler = initialize_state_handler(state_key_access, state_dir); - - let state = given_hello_world_state(); - - // when - let (lock, _s) = state_handler.load_for_mutation(&shard).unwrap(); - let _hash = state_handler.write_after_mutation(state.clone(), lock, &shard).unwrap(); - - let (result_state, _) = state_handler.load_cloned(&shard).unwrap(); - - // then - assert_eq!(state.state, result_state.state); -} - -pub fn test_ensure_subsequent_state_loads_have_same_hash() { - // given - let shard: ShardIdentifier = [49u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_ensure_subsequent_state_loads_have_same_hash", &shard); - - let state_handler = initialize_state_handler(state_key_access, state_dir); - - let (lock, initial_state) = state_handler.load_for_mutation(&shard).unwrap(); - state_handler.write_after_mutation(initial_state.clone(), lock, &shard).unwrap(); - - let (_, loaded_state_hash) = state_handler.load_cloned(&shard).unwrap(); - - assert_eq!(initial_state.hash(), loaded_state_hash); -} - -pub fn test_write_access_locks_read_until_finished() { - // here we want to test that a lock we obtain for - // mutating state locks out any read attempt that happens during that time - - // given - let shard: ShardIdentifier = [47u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_write_access_locks_read_until_finished", &shard); - - let state_handler = initialize_state_handler(state_key_access, state_dir); - - let new_state_key = "my_new_state".encode(); - let (lock, mut state_to_mutate) = state_handler.load_for_mutation(&shard).unwrap(); - - // spawn a new thread that reads state - // this thread should be blocked until the write lock is released, i.e. until - // the new state is written. We can verify this, by trying to read that state variable - // that will be inserted further down below - let new_state_key_for_read = new_state_key.clone(); - let state_handler_clone = state_handler.clone(); - let shard_for_read = shard.clone(); - let join_handle = thread::spawn(move || { - let (state_to_read, _) = state_handler_clone.load_cloned(&shard_for_read).unwrap(); - assert!(state_to_read.get(new_state_key_for_read.as_slice()).is_some()); - }); - - assert!(state_to_mutate.get(new_state_key.clone().as_slice()).is_none()); - state_to_mutate.insert(new_state_key, "mega_secret_value".encode()); - - let _hash = state_handler.write_after_mutation(state_to_mutate, lock, &shard).unwrap(); - - join_handle.join().unwrap(); -} - -pub fn test_state_handler_file_backend_is_initialized() { - let shard: ShardIdentifier = [11u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_state_handler_file_backend_is_initialized", &shard); - - let state_handler = initialize_state_handler(state_key_access, state_dir.clone()); - - assert!(state_handler.shard_exists(&shard).unwrap()); - assert!(1 <= state_handler.list_shards().unwrap().len()); // only greater equal, because there might be other (non-test) shards present - assert_eq!(1, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); // creates a first initialized file - - let _state = state_handler.load_cloned(&shard).unwrap(); - - assert_eq!(1, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); -} - -pub fn test_multiple_state_updates_create_snapshots_up_to_cache_size() { - let shard: ShardIdentifier = [17u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_state_handler_file_backend_is_initialized", &shard); - - let state_handler = initialize_state_handler(state_key_access, state_dir.clone()); - - assert_eq!(1, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); - - let hash_1 = update_state( - state_handler.as_ref(), - &shard, - ("my_key_1".encode(), "mega_secret_value".encode()), - ); - assert_eq!(2, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); - - let hash_2 = update_state( - state_handler.as_ref(), - &shard, - ("my_key_2".encode(), "mega_secret_value222".encode()), - ); - assert_eq!(3, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); - - let hash_3 = update_state( - state_handler.as_ref(), - &shard, - ("my_key_3".encode(), "mega_secret_value3".encode()), - ); - assert_eq!(3, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); - - let hash_4 = update_state( - state_handler.as_ref(), - &shard, - ("my_key_3".encode(), "mega_secret_valuenot3".encode()), - ); - assert_eq!(3, state_dir.list_state_ids_for_shard(&shard).unwrap().len()); - - assert_ne!(hash_1, hash_2); - assert_ne!(hash_1, hash_3); - assert_ne!(hash_1, hash_4); - assert_ne!(hash_2, hash_3); - assert_ne!(hash_2, hash_4); - assert_ne!(hash_3, hash_4); - - assert_eq!( - STATE_SNAPSHOTS_CACHE_SIZE, - state_dir.list_state_ids_for_shard(&shard).unwrap().len() - ); -} - -pub fn test_file_io_get_state_hash_works() { - let shard: ShardIdentifier = [21u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_file_io_get_state_hash_works", &shard); - - let file_io = TestStateFileIo::new(state_key_access, state_dir); - - let state_id = 1234u128; - let state_hash = file_io - .initialize_shard(&shard, state_id, &SgxExternalities::new(Default::default())) - .unwrap(); - assert_eq!(state_hash, file_io.compute_hash(&shard, state_id).unwrap()); - - let state_hash = file_io.write(&shard, state_id, &given_hello_world_state()).unwrap(); - assert_eq!(state_hash, file_io.compute_hash(&shard, state_id).unwrap()); -} - -pub fn test_state_files_from_handler_can_be_loaded_again() { - let shard: ShardIdentifier = [15u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_state_files_from_handler_can_be_loaded_again", &shard); - - let state_handler = initialize_state_handler(state_key_access.clone(), state_dir.clone()); - - update_state(state_handler.as_ref(), &shard, ("test_key_1".encode(), "value1".encode())); - update_state(state_handler.as_ref(), &shard, ("test_key_2".encode(), "value2".encode())); - update_state( - state_handler.as_ref(), - &shard, - ("test_key_2".encode(), "value2_updated".encode()), - ); - update_state(state_handler.as_ref(), &shard, ("test_key_3".encode(), "value3".encode())); - - // We initialize another state handler to load the state from the changes we just made. - let updated_state_handler = initialize_state_handler(state_key_access, state_dir.clone()); - - assert_eq!( - STATE_SNAPSHOTS_CACHE_SIZE, - state_dir.list_state_ids_for_shard(&shard).unwrap().len() - ); - assert_eq!( - &"value3".encode(), - updated_state_handler - .load_cloned(&shard) - .unwrap() - .0 - .state() - .get("test_key_3".encode().as_slice()) - .unwrap() - ); -} - -pub fn test_list_state_ids_ignores_files_not_matching_the_pattern() { - let shard: ShardIdentifier = [21u8; 32].into(); - let (_temp_dir, state_key_access, state_dir) = - test_setup("test_list_state_ids_ignores_files_not_matching_the_pattern", &shard); - - let file_io = TestStateFileIo::new(state_key_access, state_dir.clone()); - - let invalid_state_file_path = state_dir.shard_path(&shard).join("invalid-state.bin"); - write(&[0, 1, 2, 3, 4, 5], invalid_state_file_path).unwrap(); - - file_io - .initialize_shard(&shard, 1234, &SgxExternalities::new(Default::default())) - .unwrap(); - - assert_eq!(1, file_io.list_state_ids_for_shard(&shard).unwrap().len()); -} - -pub fn test_in_memory_state_initializes_from_shard_directory() { - let shard: ShardIdentifier = [45u8; 32].into(); - let (_temp_dir, _, state_dir) = - test_setup("test_list_state_ids_ignores_files_not_matching_the_pattern", &shard); - - let file_io = - create_in_memory_state_io_from_shards_directories(&state_dir.shards_directory()).unwrap(); - let state_initializer = - Arc::new(TestStateInitializer::new(SgxExternalities::new(Default::default()))); - let state_repository_loader = - StateSnapshotRepositoryLoader::new(file_io.clone(), state_initializer); - let state_snapshot_repository = state_repository_loader - .load_snapshot_repository(STATE_SNAPSHOTS_CACHE_SIZE) - .unwrap(); - - assert_eq!(1, file_io.get_states_for_shard(&shard).unwrap().len()); - assert!(state_snapshot_repository.shard_exists(&shard)); -} - -fn initialize_state_handler( - state_key_access: Arc, - state_dir: StateDir, -) -> Arc { - let file_io = Arc::new(TestStateFileIo::new(state_key_access, state_dir)); - let state_initializer = - Arc::new(TestStateInitializer::new(SgxExternalities::new(Default::default()))); - let state_repository_loader = - TestStateRepositoryLoader::new(file_io, state_initializer.clone()); - let state_observer = Arc::new(TestStateObserver::default()); - let state_snapshot_repository = state_repository_loader - .load_snapshot_repository(STATE_SNAPSHOTS_CACHE_SIZE) - .unwrap(); - Arc::new( - TestStateHandler::load_from_repository( - state_snapshot_repository, - state_observer, - state_initializer, - ) - .unwrap(), - ) -} - -fn update_state( - state_handler: &TestStateHandler, - shard: &ShardIdentifier, - kv_pair: (Vec, Vec), -) -> H256 { - let (lock, mut state_to_mutate) = state_handler.load_for_mutation(shard).unwrap(); - state_to_mutate.insert(kv_pair.0, kv_pair.1); - state_handler.write_after_mutation(state_to_mutate, lock, shard).unwrap() -} - -fn given_hello_world_state() -> SgxExternalities { - let key: Vec = "hello".encode(); - let value: Vec = "world".encode(); - let mut state = SgxExternalities::new(Default::default()); - state.insert(key, value); - state -} - -fn test_setup(id: &str, shard: &ShardIdentifier) -> (TempDir, Arc, StateDir) { - let temp_dir = TempDir::with_prefix(id).unwrap(); - let state_key_access = Arc::new(get_aes_repository(temp_dir.path().to_path_buf()).unwrap()); - let state_dir = StateDir::new(temp_dir.path().to_path_buf()); - state_dir.given_initialized_shard(shard); - - (temp_dir, state_key_access, state_dir) -} diff --git a/tee-worker/identity/core-primitives/stf-state-observer/Cargo.toml b/tee-worker/identity/core-primitives/stf-state-observer/Cargo.toml deleted file mode 100644 index 00729ff11b..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-observer/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "itp-stf-state-observer" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -# local deps -itp-types = { default-features = false, path = "../types" } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -log = { version = "0.4", default-features = false } -thiserror = { version = "1.0", optional = true } - -[features] -default = ["std"] -std = [ - "itp-types/std", - "log/std", - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror_sgx", -] -mocks = [] diff --git a/tee-worker/identity/core-primitives/stf-state-observer/src/error.rs b/tee-worker/identity/core-primitives/stf-state-observer/src/error.rs deleted file mode 100644 index f2f17ce3fb..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-observer/src/error.rs +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -pub type Result = core::result::Result; - -use std::boxed::Box; - -/// State Observer Error. -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Current state is empty (not set)")] - CurrentShardStateEmpty, - #[error("Could not acquire lock, lock is poisoned")] - LockPoisoning, - #[error(transparent)] - Other(#[from] Box), -} diff --git a/tee-worker/identity/core-primitives/stf-state-observer/src/lib.rs b/tee-worker/identity/core-primitives/stf-state-observer/src/lib.rs deleted file mode 100644 index 5da2bbbed9..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-observer/src/lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] -#![cfg_attr(test, feature(assert_matches))] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// Re-export module to properly feature gate sgx and regular std environment. -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use thiserror_sgx as thiserror; -} - -pub mod error; -pub mod state_observer; -pub mod traits; - -#[cfg(feature = "mocks")] -pub mod mock; diff --git a/tee-worker/identity/core-primitives/stf-state-observer/src/mock.rs b/tee-worker/identity/core-primitives/stf-state-observer/src/mock.rs deleted file mode 100644 index ce95877873..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-observer/src/mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - error::{Error, Result}, - traits::{ObserveState, UpdateState}, -}; -use core::fmt::Debug; -use itp_types::ShardIdentifier; -use log::*; -use std::vec::Vec; - -/// Observe state mock. -#[derive(Default)] -pub struct ObserveStateMock { - state: RwLock>, -} - -impl ObserveStateMock { - pub fn new(state: StateType) -> Self { - Self { state: RwLock::new(Some(state)) } - } -} - -impl ObserveState for ObserveStateMock -where - StateType: Debug, -{ - type StateType = StateType; - - fn observe_state(&self, _shard: &ShardIdentifier, observation_func: F) -> Result - where - F: FnOnce(&mut Self::StateType) -> R, - { - let mut maybe_state_lock = self.state.write().unwrap(); - - match &mut *maybe_state_lock { - Some(state) => { - debug!("State value: {:?}", state); - Ok(observation_func(state)) - }, - None => Err(Error::CurrentShardStateEmpty), - } - } -} - -/// Update state mock. -#[derive(Default)] -pub struct UpdateStateMock { - pub queued_updates: RwLock>, -} - -impl UpdateState for UpdateStateMock { - fn queue_state_update(&self, shard: ShardIdentifier, state: StateType) -> Result<()> { - let mut updates_lock = self.queued_updates.write().unwrap(); - updates_lock.push((shard, state)); - Ok(()) - } -} diff --git a/tee-worker/identity/core-primitives/stf-state-observer/src/traits.rs b/tee-worker/identity/core-primitives/stf-state-observer/src/traits.rs deleted file mode 100644 index 617e50dab4..0000000000 --- a/tee-worker/identity/core-primitives/stf-state-observer/src/traits.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::error::Result; -use itp_types::ShardIdentifier; - -/// Observe state trait. -pub trait ObserveState { - type StateType; - - /// Requires a &mut StateType because the externalities are always executed with a mutable reference. - /// Underneath it all, the environmental!() macro only knows mutable access unfortunately. - /// And since the sp-io interface is fixed and relies on the global instance created by environmental!(), - /// it forces &mut access upon us here, even though read-only access would be enough. - fn observe_state(&self, shard: &ShardIdentifier, observation_func: F) -> Result - where - F: FnOnce(&mut Self::StateType) -> R; -} - -/// Trait to queue a state update for an observer. -pub trait UpdateState { - fn queue_state_update(&self, shard: ShardIdentifier, state: StateType) -> Result<()>; -} diff --git a/tee-worker/identity/core-primitives/storage/Cargo.toml b/tee-worker/identity/core-primitives/storage/Cargo.toml deleted file mode 100644 index 544f9731f6..0000000000 --- a/tee-worker/identity/core-primitives/storage/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "itp-storage" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["chain-error"] } -derive_more = { version = "0.99.5" } -frame-metadata = { version = "15.1.0", features = ["v14"], default-features = false } -hash-db = { version = "0.15.2", default-features = false } -thiserror = { version = "1.0.26", optional = true } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# substrate deps -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-trie = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# integritee -itp-types = { default-features = false, path = "../types" } - -[dev-dependencies] -sp-state-machine = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-metadata/std", - "frame-support/std", - "hash-db/std", - "itp-types/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "sp-trie/std", - "thiserror", -] -sgx = [ - "sgx_tstd", - "thiserror-sgx", -] -test = [] diff --git a/tee-worker/identity/core-primitives/storage/src/error.rs b/tee-worker/identity/core-primitives/storage/src/error.rs deleted file mode 100644 index 9b859bfb8f..0000000000 --- a/tee-worker/identity/core-primitives/storage/src/error.rs +++ /dev/null @@ -1,43 +0,0 @@ -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use thiserror_sgx as thiserror; - -// error with std::error::Error implemented for std and sgx -#[derive(Debug, PartialEq, Eq, thiserror::Error)] -#[cfg(any(feature = "std", feature = "sgx"))] -pub enum Error { - #[error("No storage proof supplied")] - NoProofSupplied, - #[error("Supplied storage value does not match the value from the proof")] - WrongValue, - #[error("Invalid storage proof: StorageRootMismatch")] - StorageRootMismatch, - #[error("Storage value unavailable")] - StorageValueUnavailable, - #[error(transparent)] - #[cfg(feature = "std")] - Codec(#[from] codec::Error), - - // as `codec::Error` does not implement `std::error::Error` in `no-std`, - // we can't use the `#[from]` attribute. - #[error("Codec: {0}")] - #[cfg(not(feature = "std"))] - Codec(codec::Error), -} - -// error for bare `no_std`, which does not implement `std::error::Error` - -#[cfg(all(not(feature = "std"), not(feature = "sgx")))] -use derive_more::{Display, From}; - -// Simple error enum for no_std without std::error::Error implemented -#[derive(Debug, Display, PartialEq, Eq, From)] -#[cfg(all(not(feature = "std"), not(feature = "sgx")))] -pub enum Error { - NoProofSupplied, - /// Supplied storage value does not match the value from the proof - WrongValue, - /// InvalidStorageProof, - StorageRootMismatch, - StorageValueUnavailable, - Codec(codec::Error), -} diff --git a/tee-worker/identity/core-primitives/storage/src/keys.rs b/tee-worker/identity/core-primitives/storage/src/keys.rs deleted file mode 100644 index 43de4f667e..0000000000 --- a/tee-worker/identity/core-primitives/storage/src/keys.rs +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 codec::Encode; -use frame_metadata::v14::StorageHasher; -use sp_std::vec::Vec; - -pub fn storage_value_key(module_prefix: &str, storage_prefix: &str) -> Vec { - let mut bytes = sp_core::twox_128(module_prefix.as_bytes()).to_vec(); - bytes.extend(&sp_core::twox_128(storage_prefix.as_bytes())[..]); - bytes -} - -pub fn storage_map_key( - module_prefix: &str, - storage_prefix: &str, - mapkey1: &K, - hasher1: &StorageHasher, -) -> Vec { - let mut bytes = sp_core::twox_128(module_prefix.as_bytes()).to_vec(); - bytes.extend(&sp_core::twox_128(storage_prefix.as_bytes())[..]); - bytes.extend(key_hash(mapkey1, hasher1)); - bytes -} - -pub fn storage_double_map_key( - module_prefix: &str, - storage_prefix: &str, - mapkey1: &K, - hasher1: &StorageHasher, - mapkey2: &Q, - hasher2: &StorageHasher, -) -> Vec { - let mut bytes = sp_core::twox_128(module_prefix.as_bytes()).to_vec(); - bytes.extend(&sp_core::twox_128(storage_prefix.as_bytes())[..]); - bytes.extend(key_hash(mapkey1, hasher1)); - bytes.extend(key_hash(mapkey2, hasher2)); - bytes -} - -/// generates the key's hash depending on the StorageHasher selected -fn key_hash(key: &K, hasher: &StorageHasher) -> Vec { - let encoded_key = key.encode(); - match hasher { - StorageHasher::Identity => encoded_key.to_vec(), - StorageHasher::Blake2_128 => sp_core::blake2_128(&encoded_key).to_vec(), - StorageHasher::Blake2_128Concat => { - // copied from substrate Blake2_128Concat::hash since StorageHasher is not public - let x: &[u8] = encoded_key.as_slice(); - sp_core::blake2_128(x).iter().chain(x.iter()).cloned().collect::>() - }, - StorageHasher::Blake2_256 => sp_core::blake2_256(&encoded_key).to_vec(), - StorageHasher::Twox128 => sp_core::twox_128(&encoded_key).to_vec(), - StorageHasher::Twox256 => sp_core::twox_256(&encoded_key).to_vec(), - StorageHasher::Twox64Concat => sp_core::twox_64(&encoded_key).to_vec(), - } -} diff --git a/tee-worker/identity/core-primitives/storage/src/lib.rs b/tee-worker/identity/core-primitives/storage/src/lib.rs deleted file mode 100644 index 3a3b6f2a6d..0000000000 --- a/tee-worker/identity/core-primitives/storage/src/lib.rs +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -pub use error::Error; -pub use frame_metadata::v14::StorageHasher; -pub use keys::*; -pub use proof::*; -pub use verify_storage_proof::*; - -pub mod error; -pub mod keys; -pub mod proof; -pub mod verify_storage_proof; diff --git a/tee-worker/identity/core-primitives/storage/src/proof.rs b/tee-worker/identity/core-primitives/storage/src/proof.rs deleted file mode 100644 index 6b2c02c49f..0000000000 --- a/tee-worker/identity/core-primitives/storage/src/proof.rs +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Logic for checking Substrate storage proofs. - -use crate::error::Error; -use hash_db::EMPTY_PREFIX; -use sp_core::Hasher; -use sp_std::vec::Vec; -use sp_trie::{trie_types::TrieDB, HashDBT, MemoryDB, Trie, TrieDBBuilder}; - -pub type StorageProof = Vec>; - -/// This struct is used to read storage values from a subset of a Merklized database. The "proof" -/// is a subset of the nodes in the Merkle structure of the database, so that it provides -/// authentication against a known Merkle root as well as the values in the database themselves. -pub struct StorageProofChecker { - root: H::Out, - db: MemoryDB, -} - -impl StorageProofChecker { - /// Constructs a new storage proof checker. - /// - /// This returns an error if the given proof is invalid with respect to the given root. - pub fn new(root: H::Out, proof: StorageProof) -> Result { - let mut db = MemoryDB::default(); - for item in proof { - db.insert(EMPTY_PREFIX, &item); - } - let checker = StorageProofChecker { root, db }; - // Return error if trie would be invalid. - let _ = checker.trie()?; - Ok(checker) - } - - /// Reads a value from the available subset of storage. If the value cannot be read due to an - /// incomplete or otherwise invalid proof, this returns an error. - pub fn read_value(&self, key: &[u8]) -> Result>, Error> { - self.trie()? - .get(key) - .map(|value| value.map(|value| value.to_vec())) - .map_err(|_| Error::StorageValueUnavailable) - } - - fn trie(&self) -> Result, Error> { - if !self.db.contains(&self.root, EMPTY_PREFIX) { - Err(Error::StorageRootMismatch) - } else { - Ok(TrieDBBuilder::new(&self.db, &self.root).build()) - } - } - - pub fn check_proof( - root: H::Out, - storage_key: &[u8], - proof: StorageProof, - ) -> Result>, Error> { - let storage_checker = StorageProofChecker::::new(root, proof)?; - - storage_checker.read_value(storage_key) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - use sp_core::{Blake2Hasher, H256}; - use sp_state_machine::{backend::Backend, new_in_mem, prove_read}; - use sp_trie::HashKey; - - #[test] - fn storage_proof_check() { - // construct storage proof - let mut backend = new_in_mem::>(); - backend.insert( - vec![ - (None, vec![(b"key1".to_vec(), Some(b"value1".to_vec()))]), - (None, vec![(b"key2".to_vec(), Some(b"value2".to_vec()))]), - (None, vec![(b"key3".to_vec(), Some(b"value3".to_vec()))]), - // Value is too big to fit in a branch node - (None, vec![(b"key11".to_vec(), Some(vec![0u8; 32]))]), - ], - Default::default(), - ); - let root = backend.storage_root(std::iter::empty(), Default::default()).0; - let proof: StorageProof = prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key22"[..]]) - .unwrap() - .iter_nodes() - .cloned() - .collect(); - - // check proof in runtime - let checker = >::new(root, proof.clone()).unwrap(); - assert_eq!(checker.read_value(b"key1"), Ok(Some(b"value1".to_vec()))); - assert_eq!(checker.read_value(b"key2"), Ok(Some(b"value2".to_vec()))); - assert_eq!(checker.read_value(b"key11111"), Err(Error::StorageValueUnavailable)); - assert_eq!(checker.read_value(b"key22"), Ok(None)); - - // checking proof against invalid commitment fails - assert_eq!( - >::new(H256::random(), proof).err(), - Some(Error::StorageRootMismatch) - ); - } -} diff --git a/tee-worker/identity/core-primitives/storage/src/verify_storage_proof.rs b/tee-worker/identity/core-primitives/storage/src/verify_storage_proof.rs deleted file mode 100644 index fab9fda455..0000000000 --- a/tee-worker/identity/core-primitives/storage/src/verify_storage_proof.rs +++ /dev/null @@ -1,67 +0,0 @@ -use crate::{error::Error, StorageProofChecker}; -use codec::Decode; -use frame_support::ensure; -use itp_types::storage::{StorageEntry, StorageEntryVerified}; -use sp_runtime::traits::Header as HeaderT; -use sp_std::prelude::Vec; - -pub trait VerifyStorageProof { - fn verify_storage_proof( - self, - header: &Header, - ) -> Result, Error>; -} - -impl VerifyStorageProof for StorageEntry> { - fn verify_storage_proof( - self, - header: &Header, - ) -> Result, Error> { - let proof = self.proof.as_ref().ok_or(Error::NoProofSupplied)?; - let actual = StorageProofChecker::<
::Hashing>::check_proof( - *header.state_root(), - &self.key, - proof.to_vec(), - )?; - - // Todo: Why do they do it like that, we could supply the proof only and get the value from the proof directly?? - ensure!(actual == self.value, Error::WrongValue); - - Ok(StorageEntryVerified { - key: self.key, - value: self - .value - .map(|v| Decode::decode(&mut v.as_slice())) - .transpose() - .map_err(Error::Codec)?, - }) - } -} - -/// Verify a set of storage entries -pub fn verify_storage_entries( - entries: impl IntoIterator, - header: &Header, -) -> Result>, Error> -where - S: Into>>, - Header: HeaderT, - V: Decode, -{ - let iter = into_storage_entry_iter(entries); - let mut verified_entries = Vec::with_capacity(iter.size_hint().0); - - for e in iter { - verified_entries.push(e.verify_storage_proof(header)?); - } - Ok(verified_entries) -} - -pub fn into_storage_entry_iter<'a, S>( - source: impl IntoIterator + 'a, -) -> impl Iterator>> + 'a -where - S: Into>>, -{ - source.into_iter().map(|s| s.into()) -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/environmental/Cargo.toml b/tee-worker/identity/core-primitives/substrate-sgx/environmental/Cargo.toml deleted file mode 100644 index 354aa878a6..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/environmental/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "environmental" -description = "Set scope-limited values can can be accessed statically" -version = "1.1.3" -authors = ["Parity Technologies "] -license = "Apache-2.0" -edition = "2021" - -[dependencies] -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["thread"] } - -[features] -default = ["std"] -std = [] -sgx = ["sgx_tstd"] diff --git a/tee-worker/identity/core-primitives/substrate-sgx/environmental/src/lib.rs b/tee-worker/identity/core-primitives/substrate-sgx/environmental/src/lib.rs deleted file mode 100644 index 7671299615..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/environmental/src/lib.rs +++ /dev/null @@ -1,479 +0,0 @@ -// Copyright 2017-2020 Parity Technologies -// -// Licensed 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. - -//! Safe global references to stack variables. -//! -//! Set up a global reference with environmental! macro giving it a name and type. -//! Use the `using` function scoped under its name to name a reference and call a function that -//! takes no parameters yet can access said reference through the similarly placed `with` function. -//! -//! # Examples -//! -//! ``` -//! #[macro_use] extern crate environmental; -//! // create a place for the global reference to exist. -//! environmental!(counter: u32); -//! fn stuff() { -//! // do some stuff, accessing the named reference as desired. -//! counter::with(|i| *i += 1); -//! } -//! fn main() { -//! // declare a stack variable of the same type as our global declaration. -//! let mut counter_value = 41u32; -//! // call stuff, setting up our `counter` environment as a reference to our counter_value var. -//! counter::using(&mut counter_value, stuff); -//! println!("The answer is {:?}", counter_value); // will print 42! -//! stuff(); // safe! doesn't do anything. -//! } -//! ``` -//! -//! Original crate: https://github.com/paritytech/environmental/blob/master/src/lib.rs -//! The original crate does not support multithreading in `no_std` mode, see https://github.com/integritee-network/worker/issues/803. -//! Therefore, this crate introduces the sgx feature, which allows multithreading within an sgx enabled environment. -//! It should be ensured that all uses of the environmental crate within the enclave are making use of this crate, not the original one. -//! -//! Attention: The `sp-runtime-interface` still points to the original environmental crate. It can't be easily patched due -//! to this crate not being `no_std` compatible. (See https://github.com/integritee-network/worker/pull/938#discussion_r952412587). -//! However, because `sp-runtime-interface` only uses environmental in `std` mode, it should be safe to leave as is. -//! Nonetheless, it should be kept in mind that this may cause a problem in the future. - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), not(feature = "sgx")))] -compile_error!("Either feature \"std\" or feature \"sgx\" must be enabled"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -extern crate alloc; - -#[doc(hidden)] -pub use core::{ - cell::RefCell, - marker::PhantomData, - mem::{replace, transmute}, -}; - -#[doc(hidden)] -pub use alloc::{rc::Rc, vec::Vec}; - -#[doc(hidden)] -pub use std::thread::LocalKey; - -#[doc(hidden)] -#[macro_export] -macro_rules! thread_local_impl { - ($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr) => ( - use std::thread_local; - thread_local!($(#[$attr])* static $name: $t = $init); - ); -} - -/// The global inner that stores the stack of globals. -#[doc(hidden)] -pub type GlobalInner = RefCell>>>; - -/// The global type. -type Global = LocalKey>; - -#[doc(hidden)] -pub fn using R>( - global: &'static Global, - protected: &mut T, - f: F, -) -> R { - // store the `protected` reference as a pointer so we can provide it to logic running within - // `f`. - // while we record this pointer (while it's non-zero) we guarantee: - // - it will only be used once at any time (no reentrancy); - // - that no other thread will use it; and - // - that we do not use the original mutating reference while the pointer. - // exists. - global.with(|r| { - // Push the new global to the end of the stack. - r.borrow_mut().push(Rc::new(RefCell::new(protected as _))); - - // Even if `f` panics the added global will be popped. - struct PopGlobal<'a, T: 'a + ?Sized> { - global_stack: &'a GlobalInner, - } - - impl<'a, T: 'a + ?Sized> Drop for PopGlobal<'a, T> { - fn drop(&mut self) { - self.global_stack.borrow_mut().pop(); - } - } - - let _guard = PopGlobal { global_stack: r }; - - f() - }) -} - -#[doc(hidden)] -pub fn with R>( - global: &'static Global, - mutator: F, -) -> Option { - global.with(|r| { - // We always use the `last` element when we want to access the - // currently set global. - let last = r.borrow().last().cloned(); - last.map(|ptr| - // safe because it's only non-zero when it's being called from using, which - // is holding on to the underlying reference (and not using it itself) safely. - unsafe { - mutator(&mut **ptr.borrow_mut()) - }) - }) -} - -/// Declare a new global reference module whose underlying value does not contain references. -/// -/// Will create a module of a given name that contains two functions: -/// -/// * `pub fn using R>(protected: &mut $t, f: F) -> R` -/// This executes `f`, returning its value. During the call, the module's reference is set to -/// be equal to `protected`. -/// * `pub fn with R>(f: F) -> Option` -/// This executes `f`, returning `Some` of its value if called from code that is being executed -/// as part of a `using` call. If not, it returns `None`. `f` is provided with one argument: the -/// same reference as provided to the most recent `using` call. -/// -/// # Examples -/// -/// Initializing the global context with a given value. -/// -/// ```rust -/// #[macro_use] extern crate environmental; -/// environmental!(counter: u32); -/// fn main() { -/// let mut counter_value = 41u32; -/// counter::using(&mut counter_value, || { -/// let odd = counter::with(|value| -/// if *value % 2 == 1 { -/// *value += 1; true -/// } else { -/// *value -= 3; false -/// }).unwrap(); // safe because we're inside a counter::using -/// println!("counter was {}", match odd { true => "odd", _ => "even" }); -/// }); -/// -/// println!("The answer is {:?}", counter_value); // 42 -/// } -/// ``` -/// -/// Roughly the same, but with a trait object: -/// -/// ```rust -/// #[macro_use] extern crate environmental; -/// -/// trait Increment { fn increment(&mut self); } -/// -/// impl Increment for i32 { -/// fn increment(&mut self) { *self += 1 } -/// } -/// -/// environmental!(val: dyn Increment + 'static); -/// -/// fn main() { -/// let mut local = 0i32; -/// val::using(&mut local, || { -/// val::with(|v| for _ in 0..5 { v.increment() }); -/// }); -/// -/// assert_eq!(local, 5); -/// } -/// ``` -#[macro_export] -macro_rules! environmental { - ($name:ident : $t:ty) => { - #[allow(non_camel_case_types)] - struct $name { __private_field: () } - - $crate::thread_local_impl! { - static GLOBAL: $crate::GlobalInner<$t> = Default::default() - } - - impl $name { - #[allow(unused_imports)] - - pub fn using R>( - protected: &mut $t, - f: F - ) -> R { - $crate::using(&GLOBAL, protected, f) - } - - pub fn with R>( - f: F - ) -> Option { - $crate::with(&GLOBAL, |x| f(x)) - } - } - }; - ($name:ident : trait @$t:ident [$($args:ty,)*]) => { - #[allow(non_camel_case_types, dead_code)] - struct $name { __private_field: () } - - $crate::thread_local_impl! { - static GLOBAL: $crate::GlobalInner<(dyn $t<$($args),*> + 'static)> - = Default::default() - } - - impl $name { - #[allow(unused_imports)] - - pub fn using R>( - protected: &mut dyn $t<$($args),*>, - f: F - ) -> R { - let lifetime_extended = unsafe { - $crate::transmute::<&mut dyn $t<$($args),*>, &mut (dyn $t<$($args),*> + 'static)>(protected) - }; - $crate::using(&GLOBAL, lifetime_extended, f) - } - - pub fn with FnOnce(&'a mut (dyn $t<$($args),*> + 'a)) -> R>( - f: F - ) -> Option { - $crate::with(&GLOBAL, |x| f(x)) - } - } - }; - ($name:ident<$traittype:ident> : trait $t:ident <$concretetype:ty>) => { - #[allow(non_camel_case_types, dead_code)] - struct $name { _private_field: $crate::PhantomData } - - $crate::thread_local_impl! { - static GLOBAL: $crate::GlobalInner<(dyn $t<$concretetype> + 'static)> - = Default::default() - } - - impl $name { - #[allow(unused_imports)] - pub fn using R>( - protected: &mut dyn $t, - f: F - ) -> R { - let lifetime_extended = unsafe { - $crate::transmute::<&mut dyn $t, &mut (dyn $t<$concretetype> + 'static)>(protected) - }; - $crate::using(&GLOBAL, lifetime_extended, f) - } - - pub fn with FnOnce(&'a mut (dyn $t<$concretetype> + 'a)) -> R>( - f: F - ) -> Option { - $crate::with(&GLOBAL, |x| f(x)) - } - } - }; - ($name:ident : trait $t:ident <>) => { $crate::environmental! { $name : trait @$t [] } }; - ($name:ident : trait $t:ident < $($args:ty),* $(,)* >) => { - $crate::environmental! { $name : trait @$t [$($args,)*] } - }; - ($name:ident : trait $t:ident) => { $crate::environmental! { $name : trait @$t [] } }; -} - -#[cfg(test)] -mod tests { - // Test trait in item position - #[allow(dead_code)] - mod trait_test { - trait Test {} - - environmental!(item_positon_trait: trait Test); - } - - // Test type in item position - #[allow(dead_code)] - mod type_test { - environmental!(item_position_type: u32); - } - - #[test] - fn simple_works() { - environmental!(counter: u32); - - fn stuff() { - counter::with(|value| *value += 1); - } - - // declare a stack variable of the same type as our global declaration. - let mut local = 41u32; - - // call stuff, setting up our `counter` environment as a reference to our local counter var. - counter::using(&mut local, stuff); - assert_eq!(local, 42); - stuff(); // safe! doesn't do anything. - assert_eq!(local, 42); - } - - #[test] - fn overwrite_with_lesser_lifetime() { - environmental!(items: Vec); - - let mut local_items = vec![1, 2, 3]; - items::using(&mut local_items, || { - let dies_at_end = vec![4, 5, 6]; - items::with(|items| *items = dies_at_end); - }); - - assert_eq!(local_items, vec![4, 5, 6]); - } - - #[test] - fn declare_with_trait_object() { - trait Foo { - fn get(&self) -> i32; - fn set(&mut self, x: i32); - } - - impl Foo for i32 { - fn get(&self) -> i32 { - *self - } - fn set(&mut self, x: i32) { - *self = x - } - } - - environmental!(foo: dyn Foo + 'static); - - fn stuff() { - foo::with(|value| { - let new_val = value.get() + 1; - value.set(new_val); - }); - } - - let mut local = 41i32; - foo::using(&mut local, stuff); - - assert_eq!(local, 42); - - stuff(); // doesn't do anything. - - assert_eq!(local, 42); - } - - #[test] - fn unwind_recursive() { - use std::panic; - - environmental!(items: Vec); - - let panicked = panic::catch_unwind(|| { - let mut local_outer = vec![1, 2, 3]; - - items::using(&mut local_outer, || { - let mut local_inner = vec![4, 5, 6]; - items::using(&mut local_inner, || { - panic!("are you unsafe?"); - }) - }); - }) - .is_err(); - - assert!(panicked); - - let mut was_cleared = true; - items::with(|_items| was_cleared = false); - - assert!(was_cleared); - } - - #[test] - fn use_non_static_trait() { - trait Sum { - fn sum(&self) -> usize; - } - impl Sum for &[usize] { - fn sum(&self) -> usize { - self.iter().fold(0, |a, c| a + c) - } - } - - environmental!(sum: trait Sum); - let numbers = vec![1, 2, 3, 4, 5]; - let mut numbers = &numbers[..]; - let got_sum = sum::using(&mut numbers, || sum::with(|x| x.sum())).unwrap(); - - assert_eq!(got_sum, 15); - } - - #[test] - fn stacking_globals() { - trait Sum { - fn sum(&self) -> usize; - } - impl Sum for &[usize] { - fn sum(&self) -> usize { - self.iter().fold(0, |a, c| a + c) - } - } - - environmental!(sum: trait Sum); - let numbers = vec![1, 2, 3, 4, 5]; - let mut numbers = &numbers[..]; - let got_sum = sum::using(&mut numbers, || { - sum::with(|_| { - let numbers2 = vec![1, 2, 3, 4, 5, 6]; - let mut numbers2 = &numbers2[..]; - sum::using(&mut numbers2, || sum::with(|x| x.sum())) - }) - }) - .unwrap() - .unwrap(); - - assert_eq!(got_sum, 21); - - assert!(sum::with(|_| ()).is_none()); - } - - #[test] - fn use_generic_trait() { - trait Plus { - fn plus42() -> usize; - } - struct ConcretePlus; - impl Plus for ConcretePlus { - fn plus42() -> usize { - 42 - } - } - trait Multiplier { - fn mul_and_add(&self) -> usize; - } - impl<'a, P: Plus> Multiplier

for &'a [usize] { - fn mul_and_add(&self) -> usize { - self.iter().fold(1, |a, c| a * c) + P::plus42() - } - } - - let numbers = vec![1, 2, 3]; - let mut numbers = &numbers[..]; - let out = foo::::using(&mut numbers, || { - foo::::with(|x| x.mul_and_add()) - }) - .unwrap(); - - assert_eq!(out, 6 + 42); - environmental!(foo: trait Multiplier); - } -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/Cargo.toml b/tee-worker/identity/core-primitives/substrate-sgx/externalities/Cargo.toml deleted file mode 100644 index c413e88a7a..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "itp-sgx-externalities" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG and Parity Technologies '] -edition = "2021" - -[dependencies] -# no_std -codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false, features = ["derive", "chain-error"] } -derive_more = "0.99.16" -log = { version = "0.4", default-features = false } -postcard = { version = "0.7.2", default-features = false, features = ["alloc"] } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -# sgx dependencies -sgx_tstd = { optional = true, features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } - -# substrate -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local -environmental = { default-features = false, path = "../environmental" } -itp-hashing = { default-features = false, path = "../../hashing" } - -[dev-dependencies] -itp-storage = { default-features = false, path = "../../storage" } - -[features] -default = ["std"] -std = [ - "codec/std", - "environmental/std", - "itp-hashing/std", - "log/std", - "postcard/use-std", - "serde/std", - "itp-storage/std", - # substrate - "sp-core/std", -] -sgx = [ - "sgx_tstd", - "environmental/sgx", -] diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/bypass.rs b/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/bypass.rs deleted file mode 100644 index dcd5bd9f9c..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/bypass.rs +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Converts maps to vecs for serialization. -//! from https://github.com/DenisKolodin/vectorize -//! -//! `bypass` is necessary to force deriving serialization of complex type specs. - -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -#[allow(unused)] -pub fn serialize<'a, T, S>(target: T, ser: S) -> Result -where - S: Serializer, - T: Serialize + 'a, -{ - serde::Serialize::serialize(&target, ser) -} - -#[allow(unused)] -pub fn deserialize<'de, T, D>(des: D) -> Result -where - D: Deserializer<'de>, - T: Deserialize<'de>, -{ - serde::Deserialize::deserialize(des) -} - -#[cfg(test)] -mod tests { - use serde::{de::DeserializeOwned, Deserialize, Serialize}; - use std::fmt; - - trait Requirement: - DeserializeOwned + Serialize + Clone + fmt::Debug + Sync + Send + 'static - { - } - - trait ComplexSpec: Requirement {} - - #[derive(Debug, Serialize, Deserialize)] - struct MyComplexType { - #[serde(with = "super")] // = "vectorize::bypass" - inner: Option, - } -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/codec_impl.rs b/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/codec_impl.rs deleted file mode 100644 index b65f9003f1..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/codec_impl.rs +++ /dev/null @@ -1,149 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Implement `parity-scale-codec` for the externalities. -//! -//! This is necessary workaround, as `Encode` and `Decode` can't directly be implemented on `HashMap` or `BTreeMap`. - -use codec::{Decode, Encode, Input}; -use serde::{de::DeserializeOwned, Serialize}; -use std::{vec, vec::Vec}; - -use crate::{SgxExternalitiesDiffType, SgxExternalitiesType}; - -impl Encode for SgxExternalitiesType { - fn encode(&self) -> Vec { - encode_with_serialize(&self) - } -} - -impl Decode for SgxExternalitiesType { - fn decode(input: &mut I) -> Result { - decode_with_deserialize(input) - } -} - -impl Encode for SgxExternalitiesDiffType { - fn encode(&self) -> Vec { - encode_with_serialize(&self) - } -} - -impl Decode for SgxExternalitiesDiffType { - fn decode(input: &mut I) -> Result { - decode_with_deserialize(input) - } -} - -fn encode_with_serialize(source: &T) -> Vec { - // We unwrap on purpose here in order to make sure we notice when something goes wrong. - // Before we returned an empty vec and logged the error. But this could go unnoticed in the - // caller and cause problems (in case the empty vec is also something valid) - postcard::to_allocvec(source).unwrap() -} - -fn decode_with_deserialize( - input: &mut I, -) -> Result { - let input_length = input - .remaining_len()? - .ok_or_else(|| codec::Error::from("Could not read length from input data"))?; - - let mut buff = vec![0u8; input_length]; - - input.read(&mut buff)?; - - postcard::from_bytes::<'_, T>(buff.as_slice()).map_err(|e| { - log::error!("deserialization failed: {:?}", e); - codec::Error::from("Could not decode with deserialize") - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{InternalMap, SgxExternalities}; - use std::{ - collections::hash_map::DefaultHasher, - hash::{Hash, Hasher}, - }; - - #[test] - fn serializing_externalities_type_works() { - ensure_serialize_roundtrip_succeeds(create_default_state()); - } - - #[test] - fn serializing_externalities_diff_type_works() { - ensure_serialize_roundtrip_succeeds(create_default_state_diff()); - } - - #[test] - fn serializing_externalities_works() { - let externalities = SgxExternalities { - state: create_default_state(), - state_diff: create_default_state_diff(), - }; - - ensure_serialize_roundtrip_succeeds(externalities); - } - - #[test] - fn encoding_decoding_preserves_order() { - let externalities = create_default_state(); - let encoded_externalities = externalities.encode(); - let decoded_externalities: SgxExternalitiesType = - Decode::decode(&mut encoded_externalities.as_slice()).unwrap(); - let encoded_second_time_externalities = decoded_externalities.encode(); - - assert_eq!( - calculate_hash(&encoded_externalities), - calculate_hash(&encoded_second_time_externalities) - ); - } - - fn create_default_state_diff() -> SgxExternalitiesDiffType { - let mut map = InternalMap::>>::new(); - map.insert(Encode::encode("dings"), Some(Encode::encode("other"))); - map.insert(Encode::encode("item"), Some(Encode::encode("crate"))); - map.insert(Encode::encode("key"), None); - SgxExternalitiesDiffType(map) - } - - fn create_default_state() -> SgxExternalitiesType { - let mut map = InternalMap::>::new(); - map.insert(Encode::encode("dings"), Encode::encode("other")); - map.insert(Encode::encode("item"), Encode::encode("crate")); - SgxExternalitiesType(map) - } - - fn ensure_serialize_roundtrip_succeeds< - T: Serialize + DeserializeOwned + std::cmp::PartialEq + std::fmt::Debug, - >( - item: T, - ) { - let serialized_item = postcard::to_allocvec(&item).unwrap(); - let deserialized_item = postcard::from_bytes::<'_, T>(serialized_item.as_slice()).unwrap(); - assert_eq!(item, deserialized_item); - } - - fn calculate_hash(t: &T) -> u64 { - let mut s = DefaultHasher::new(); - t.hash(&mut s); - s.finish() - } -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/lib.rs b/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/lib.rs deleted file mode 100644 index f417c88286..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/lib.rs +++ /dev/null @@ -1,470 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(feature = "sgx")] -extern crate sgx_tstd as std; - -use codec::{Decode, Encode, EncodeAppend}; -use core::ops::Bound; -use derive_more::{Deref, DerefMut, From, IntoIterator}; -use itp_hashing::Hash; -use serde::{Deserialize, Serialize}; -use sp_core::{hashing::blake2_256, H256}; -use std::{collections::BTreeMap, fmt::Debug, vec, vec::Vec}; - -pub use scope_limited::{set_and_run_with_externalities, with_externalities}; - -// Unfortunately we cannot use `serde_with::serde_as` to serialize our map (which would be very convenient) -// because it has pulls in the serde and serde_json dependency with `std`, not `default-features=no`. -// Instead we use https://github.com/DenisKolodin/vectorize which is very little code, copy-pasted -// directly into this code base. -//use serde_with::serde_as; - -mod codec_impl; -mod scope_limited; -// These are used to serialize a map with keys that are not string. -mod bypass; -mod vectorize; - -type InternalMap = BTreeMap, V>; - -#[derive(From, Deref, DerefMut, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct SgxExternalitiesType(#[serde(with = "vectorize")] InternalMap>); - -#[derive( - From, - Deref, - DerefMut, - Clone, - Debug, - Default, - PartialEq, - Eq, - Serialize, - Deserialize, - IntoIterator, -)] -pub struct SgxExternalitiesDiffType(#[serde(with = "vectorize")] InternalMap>>); - -#[derive(Clone, Debug, Default, PartialEq, Eq, Encode, Decode, Serialize, Deserialize)] -pub struct SgxExternalities { - pub state: SgxExternalitiesType, - pub state_diff: SgxExternalitiesDiffType, -} - -pub trait StateHash { - fn hash(&self) -> H256; -} - -impl StateHash for SgxExternalities { - fn hash(&self) -> H256 { - self.state.using_encoded(blake2_256).into() - } -} - -impl Hash for SgxExternalities { - fn hash(&self) -> H256 { - ::hash(self) - } -} - -pub trait SgxExternalitiesTrait { - type SgxExternalitiesType; - type SgxExternalitiesDiffType; - - // Create new Externaltiies with empty diff. - fn new(state: Self::SgxExternalitiesType) -> Self; - - fn state(&self) -> &Self::SgxExternalitiesType; - - fn state_diff(&self) -> &Self::SgxExternalitiesDiffType; - - fn insert(&mut self, k: Vec, v: Vec) -> Option>; - - /// Append a value to an existing key. - fn append(&mut self, k: Vec, v: Vec); - - fn remove(&mut self, k: &[u8]) -> Option>; - - fn get(&self, k: &[u8]) -> Option<&Vec>; - - fn contains_key(&self, k: &[u8]) -> bool; - - /// Get the next key in state after the given one (excluded) in lexicographic order. - fn next_storage_key(&self, key: &[u8]) -> Option>; - - /// Reads all keys and values under given prefix - fn iter_prefix( - &self, - key_prefix: &[u8], - ) -> Option>; - - /// Clears all values that match the given key prefix. - fn clear_prefix(&mut self, key_prefix: &[u8], maybe_limit: Option) -> u32; - - /// Prunes the state diff. - fn prune_state_diff(&mut self); - - /// Execute the given closure while `self` is set as externalities. - /// - /// Returns the result of the given closure. - fn execute_with(&mut self, f: impl FnOnce() -> R) -> R; -} - -impl SgxExternalitiesTrait for SgxExternalities -where - SgxExternalitiesType: Encode + Decode, - SgxExternalitiesDiffType: Encode + Decode, -{ - type SgxExternalitiesType = SgxExternalitiesType; - type SgxExternalitiesDiffType = SgxExternalitiesDiffType; - - fn new(state: Self::SgxExternalitiesType) -> Self { - Self { state, state_diff: Default::default() } - } - - fn state(&self) -> &Self::SgxExternalitiesType { - &self.state - } - - fn state_diff(&self) -> &Self::SgxExternalitiesDiffType { - &self.state_diff - } - - fn insert(&mut self, key: Vec, value: Vec) -> Option> { - self.state_diff.insert(key.clone(), Some(value.clone())); - self.state.insert(key, value) - } - - fn append(&mut self, key: Vec, value: Vec) { - let current = self.state.entry(key.clone()).or_default(); - let updated_value = StorageAppend::new(current).append(value); - self.state_diff.insert(key, Some(updated_value)); - } - - fn remove(&mut self, key: &[u8]) -> Option> { - self.state_diff.insert(key.to_vec(), None); - self.state.remove(key) - } - - fn get(&self, key: &[u8]) -> Option<&Vec> { - self.state.get(key) - } - - fn contains_key(&self, key: &[u8]) -> bool { - self.state.contains_key(key) - } - - fn next_storage_key(&self, key: &[u8]) -> Option> { - let range = (Bound::Excluded(key), Bound::Unbounded); - self.state.range::<[u8], _>(range).next().map(|(k, _v)| k.to_vec()) // directly return k as _v is never None in our case - } - - fn prune_state_diff(&mut self) { - self.state_diff.clear(); - } - - // Note: This implementation only works for keys encoded with Blake2_128Concat - fn iter_prefix( - &self, - key_prefix: &[u8], - ) -> Option> { - // The size of the hash part in Blake2_128Concat (16 bytes for blake2_128) - const HASH_PART_SIZE: usize = 16; - - let key_values = self - .state - .range::<[u8], _>((Bound::Included(key_prefix), Bound::Unbounded)) - .take_while(|(k, _)| k.starts_with(key_prefix)) - .filter_map(|(encoded_key, encoded_value)| { - let suffix_start = key_prefix.len() + HASH_PART_SIZE; - if encoded_key.len() > suffix_start { - let suffix = &encoded_key[suffix_start..]; - let decoded_key = K::decode(&mut &suffix[..]).ok(); - let decoded_value = V::decode(&mut &encoded_value[..]).ok(); - match (decoded_key, decoded_value) { - (Some(key), Some(value)) => Some((key, value)), - _ => None, - } - } else { - None - } - }) - .collect::>(); - - if key_values.is_empty() { - None - } else { - Some(key_values) - } - } - - fn clear_prefix(&mut self, key_prefix: &[u8], _maybe_limit: Option) -> u32 { - // Inspired by Substrate https://github.com/paritytech/substrate/blob/c8653447fc8ef8d95a92fe164c96dffb37919e85/primitives/state-machine/src/basic.rs#L242-L254 - let to_remove = self - .state - .range::<[u8], _>((Bound::Included(key_prefix), Bound::Unbounded)) - .map(|(k, _)| k) - .take_while(|k| k.starts_with(key_prefix)) - .cloned() - .collect::>(); - - let count = to_remove.len() as u32; - for key in to_remove { - self.remove(&key); - } - count - } - - fn execute_with(&mut self, f: impl FnOnce() -> R) -> R { - set_and_run_with_externalities(self, f) - } -} - -/// Results concerning an operation to remove many keys. -#[derive(codec::Encode, codec::Decode)] -#[must_use] -pub struct MultiRemovalResults { - /// A continuation cursor which, if `Some` must be provided to the subsequent removal call. - /// If `None` then all removals are complete and no further calls are needed. - pub maybe_cursor: Option>, - /// The number of items removed from the backend database. - pub backend: u32, - /// The number of unique keys removed, taking into account both the backend and the overlay. - pub unique: u32, - /// The number of iterations (each requiring a storage seek/read) which were done. - pub loops: u32, -} - -impl MultiRemovalResults { - /// Deconstruct into the internal components. - /// - /// Returns `(maybe_cursor, backend, unique, loops)`. - pub fn deconstruct(self) -> (Option>, u32, u32, u32) { - (self.maybe_cursor, self.backend, self.unique, self.loops) - } -} - -/// Auxialiary structure for appending a value to a storage item. -/// Taken from https://github.com/paritytech/substrate/blob/master/primitives/state-machine/src/ext.rs -pub(crate) struct StorageAppend<'a>(&'a mut Vec); - -impl<'a> StorageAppend<'a> { - /// Create a new instance using the given `storage` reference. - pub fn new(storage: &'a mut Vec) -> Self { - Self(storage) - } - - /// Append the given `value` to the storage item. - /// - /// If appending fails, `[value]` is stored in the storage item. - pub fn append(&mut self, value: Vec) -> Vec { - let value = vec![EncodeOpaqueValue(value)]; - - let item = core::mem::take(self.0); - - *self.0 = match Vec::::append_or_new(item, &value) { - Ok(item) => item, - Err(_) => { - log::error!("Failed to append value, resetting storage item to input value."); - value.encode() - }, - }; - (*self.0).to_vec() - } -} - -/// Implement `Encode` by forwarding the stored raw vec. -struct EncodeOpaqueValue(Vec); - -impl Encode for EncodeOpaqueValue { - fn using_encoded R>(&self, f: F) -> R { - f(&self.0) - } -} - -#[cfg(test)] -pub mod tests { - - use super::*; - use itp_storage::{storage_double_map_key, storage_map_key, StorageHasher}; - - #[test] - fn mutating_externalities_through_environmental_variable_works() { - let mut externalities = SgxExternalities::default(); - - externalities.execute_with(|| { - with_externalities(|e| { - e.insert("building".encode(), "empire_state".encode()); - e.insert("house".encode(), "ginger_bread".encode()); - }) - .unwrap() - }); - - let state_len = - externalities.execute_with(|| with_externalities(|e| e.state.0.len()).unwrap()); - - assert_eq!(2, state_len); - } - - #[test] - fn basic_externalities_is_empty() { - let ext = SgxExternalities::default(); - assert!(ext.state.0.is_empty()); - } - - #[test] - fn storage_append_works() { - let mut data = Vec::new(); - let mut append = StorageAppend::new(&mut data); - append.append(1u32.encode()); - let updated_data = append.append(2u32.encode()); - drop(append); - - assert_eq!(Vec::::decode(&mut &data[..]).unwrap(), vec![1, 2]); - assert_eq!(updated_data, data); - - // Initialize with some invalid data - let mut data = vec![1]; - let mut append = StorageAppend::new(&mut data); - append.append(1u32.encode()); - append.append(2u32.encode()); - drop(append); - - assert_eq!(Vec::::decode(&mut &data[..]).unwrap(), vec![1, 2]); - } - - #[test] - #[should_panic(expected = "already borrowed: BorrowMutError")] - fn nested_with_externalities_panics() { - let mut ext = SgxExternalities::default(); - - ext.execute_with(|| { - with_externalities(|_| with_externalities(|_| unreachable!("panics before")).unwrap()) - .unwrap(); - }); - } - - #[test] - fn nesting_execute_with_uses_the_latest_externalities() { - let mut ext = SgxExternalities::default(); - let mut ext2 = ext.clone(); - - let hello = b"hello".to_vec(); - let world = b"world".to_vec(); - - ext.execute_with(|| { - with_externalities(|e| { - e.insert(hello.clone(), hello.clone()); - }) - .unwrap(); - - ext2.execute_with(|| { - // `with_externalities` uses the latest set externalities defined by the last - // `set_and_run_with_externalities` call. - with_externalities(|e| { - e.insert(world.clone(), world.clone()); - }) - .unwrap(); - }); - }); - - assert_eq!(ext.get(&hello), Some(&hello)); - assert_eq!(ext2.get(&world), Some(&world)); - - // ext1 and ext2 are unrelated. - assert_eq!(ext.get(&world), None); - } - - #[test] - fn clear_prefix_works() { - let mut externalities = SgxExternalities::default(); - let non_house_key = b"window house".to_vec(); - let non_house_value = b"test_string".to_vec(); - // Fill state. - externalities.execute_with(|| { - with_externalities(|e| { - e.insert(b"house_building".to_vec(), b"empire_state".to_vec()); - e.insert(b"house".to_vec(), b"ginger_bread".to_vec()); - e.insert(b"house door".to_vec(), b"right".to_vec()); - e.insert(non_house_key.clone(), non_house_value.clone()); - }) - .unwrap() - }); - let state_len = - externalities.execute_with(|| with_externalities(|e| e.state.0.len()).unwrap()); - assert_eq!(state_len, 4); - - let number_of_removed_items = externalities - .execute_with(|| with_externalities(|e| e.clear_prefix(b"house", None)).unwrap()); - assert_eq!(number_of_removed_items, 3); - - let state_len = - externalities.execute_with(|| with_externalities(|e| e.state.0.len()).unwrap()); - assert_eq!(state_len, 1); - let stored_value = externalities.execute_with(|| { - with_externalities(|e| { - assert_eq!(e.get(&non_house_key).unwrap().clone(), non_house_value) - }) - }); - assert!(stored_value.is_some()); - } - - #[test] - fn iter_prefix_works() { - let mut externalities = SgxExternalities::default(); - - let key_1 = storage_double_map_key( - "Pallet", - "Storage", - &1_u32, - &StorageHasher::Blake2_128Concat, - &2_u32, - &StorageHasher::Blake2_128Concat, - ); - let key_2 = storage_double_map_key( - "Pallet", - "Storage", - &1_u32, - &StorageHasher::Blake2_128Concat, - &3_u32, - &StorageHasher::Blake2_128Concat, - ); - let prefix_key = - storage_map_key("Pallet", "Storage", &1_u32, &StorageHasher::Blake2_128Concat); - - // Fill state. - externalities.execute_with(|| { - with_externalities(|e| { - e.insert(key_1, 10_u32.encode()); - e.insert(key_2, 20_u32.encode()); - }) - .unwrap() - }); - // Perform iter prefix - externalities.execute_with(|| { - with_externalities(|e| { - let values = e.iter_prefix::(&prefix_key).unwrap(); - assert_eq!(values, [(2, 10), (3, 20)]); - }) - .unwrap() - }); - } -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/scope_limited.rs b/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/scope_limited.rs deleted file mode 100644 index 55c9a9e4d7..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/scope_limited.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Stores the externalities in an `environmental` value to make it scope limited available. - -use crate::SgxExternalities; - -environmental::environmental!(ext: SgxExternalities); - -/// Set the given externalities while executing the given closure. To get access to the -/// externalities while executing the given closure [`with_externalities`] grants access to them. -/// The externalities are only set for the same thread this function was called from. -pub fn set_and_run_with_externalities R, R>(ext: &mut SgxExternalities, f: F) -> R { - ext::using(ext, f) -} - -/// Execute the given closure with the currently set externalities. -/// -/// Returns `None` if no externalities are set or `Some(_)` with the result of the closure. -/// -/// Panics with `already borrowed: BorrowMutError` if calls to `with_externalities` are nested. -pub fn with_externalities R, R>(f: F) -> Option { - ext::with(f) -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/vectorize.rs b/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/vectorize.rs deleted file mode 100644 index d2203902ae..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/externalities/src/vectorize.rs +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. -*/ - -//! Converts maps to vecs for serialization. -//! from https://github.com/DenisKolodin/vectorize - -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::{iter::FromIterator, vec::Vec}; - -pub fn serialize<'a, T, K, V, S>(target: T, ser: S) -> Result -where - S: Serializer, - T: IntoIterator, - K: Serialize + 'a, - V: Serialize + 'a, -{ - let container: Vec<_> = target.into_iter().collect(); - serde::Serialize::serialize(&container, ser) -} - -pub fn deserialize<'de, T, K, V, D>(des: D) -> Result -where - D: Deserializer<'de>, - T: FromIterator<(K, V)>, - K: Deserialize<'de>, - V: Deserialize<'de>, -{ - let container: Vec<_> = serde::Deserialize::deserialize(des)?; - Ok(container.into_iter().collect()) -} - -#[cfg(test)] -mod tests { - use crate::vectorize; - use serde::{Deserialize, Serialize}; - use std::collections::HashMap; - - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)] - struct MyKey { - one: String, - two: u16, - more: Vec, - } - - #[derive(Debug, Serialize, Deserialize)] - struct MyComplexType { - #[serde(with = "vectorize")] - map: HashMap, - } - - #[test] - fn it_works() -> Result<(), Box> { - let key = MyKey { one: "1".into(), two: 2, more: vec![1, 2, 3] }; - let mut map = HashMap::new(); - map.insert(key.clone(), "value".into()); - let instance = MyComplexType { map }; - let serialized = postcard::to_allocvec(&instance)?; - let deserialized: MyComplexType = postcard::from_bytes(&serialized)?; - let expected_value = "value".to_string(); - assert_eq!(deserialized.map.get(&key), Some(&expected_value)); - Ok(()) - } -} diff --git a/tee-worker/identity/core-primitives/substrate-sgx/sp-io/Cargo.toml b/tee-worker/identity/core-primitives/substrate-sgx/sp-io/Cargo.toml deleted file mode 100644 index 0600c8a4b6..0000000000 --- a/tee-worker/identity/core-primitives/substrate-sgx/sp-io/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "sp-io" -version = "7.0.0" -authors = ['Trust Computing GmbH ', 'Integritee AG and Parity Technologies '] -edition = "2021" -license = "Apache-2.0" - -[dependencies] -codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false } -libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] } -log = { version = "0.4", default-features = false } - -itp-sgx-externalities = { default-features = false, path = "../externalities" } -sgx_tstd = { optional = true, features = ["untrusted_fs", "net", "backtrace"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } - -# Substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "log/std", - "sp-core/std", - "codec/std", - "libsecp256k1/std", - "itp-sgx-externalities/std", -] -sgx = [ - "sgx_tstd", - "itp-sgx-externalities/sgx", -] - -# These two features are used for `no_std` builds for the environments which already provides -# `#[panic_handler]`, `#[alloc_error_handler]` and `#[global_allocator]`. -# -# For the regular wasm sgx-runtime builds those are not used. -disable_panic_handler = [] -disable_oom = [] -disable_allocator = [] diff --git a/tee-worker/identity/core-primitives/test/Cargo.toml b/tee-worker/identity/core-primitives/test/Cargo.toml deleted file mode 100644 index 33805a23a7..0000000000 --- a/tee-worker/identity/core-primitives/test/Cargo.toml +++ /dev/null @@ -1,70 +0,0 @@ -[package] -name = "itp-test" -version = "0.1.0" -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } - -# sgx deps -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# substrate deps -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-io = { default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"], path = "../../core-primitives/substrate-sgx/sp-io" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# local deps -itp-node-api = { path = "../node-api", default-features = false } -itp-node-api-metadata-provider = { path = "../node-api/metadata-provider", default-features = false } -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-externalities = { default-features = false, path = "../substrate-sgx/externalities" } -itp-stf-interface = { path = "../stf-interface", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-storage = { path = "../storage", default-features = false } -itp-types = { path = "../types", default-features = false, features = ["test"] } - -# litentry -hex = { version = "0.4.3", default-features = false } -lc-teebag-storage = { path = "../../litentry/core/teebag-storage", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-node-api-metadata-provider/std", - "itp-node-api/std", - "itp-ocall-api/std", - "itp-sgx-crypto/std", - "itp-sgx-externalities/std", - "itp-stf-interface/std", - "itp-stf-primitives/std", - "itp-stf-state-handler/std", - "itp-storage/std", - "itp-types/std", - "log/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "litentry-primitives/std", - "lc-teebag-storage/std", -] -sgx = [ - "itp-node-api/sgx", - "itp-node-api-metadata-provider/sgx", - "itp-sgx-crypto/sgx", - "itp-sgx-externalities/sgx", - "itp-stf-state-handler/sgx", - "jsonrpc-core_sgx", - "sgx_tstd", - "litentry-primitives/sgx", -] diff --git a/tee-worker/identity/core-primitives/test/src/lib.rs b/tee-worker/identity/core-primitives/test/src/lib.rs deleted file mode 100644 index 87759a147b..0000000000 --- a/tee-worker/identity/core-primitives/test/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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(not(feature = "std"), no_std)] - -//! Itp-test crate which contains mocks and soon some fixtures. - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -extern crate alloc; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use jsonrpc_core_sgx as jsonrpc_core; -} - -pub mod mock; diff --git a/tee-worker/identity/core-primitives/test/src/mock/handle_state_mock.rs b/tee-worker/identity/core-primitives/test/src/mock/handle_state_mock.rs deleted file mode 100644 index 9c8710935d..0000000000 --- a/tee-worker/identity/core-primitives/test/src/mock/handle_state_mock.rs +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::{SgxRwLock as RwLock, SgxRwLockWriteGuard as RwLockWriteGuard}; - -#[cfg(feature = "std")] -use std::sync::{RwLock, RwLockWriteGuard}; - -use itp_sgx_externalities::{SgxExternalities as StfState, StateHash}; - -use itp_stf_state_handler::{ - error::{Error, Result}, - handle_state::HandleState, - query_shard_state::QueryShardState, -}; -use itp_types::{ShardIdentifier, H256}; -use std::{collections::HashMap, format, vec::Vec}; - -/// Mock implementation for the `HandleState` trait. -/// -/// Uses an in-memory state, in a `HashMap`. To be used in unit tests. -#[derive(Default)] -pub struct HandleStateMock { - state_map: RwLock>, -} - -impl HandleStateMock { - pub fn from_shard(shard: ShardIdentifier) -> Result { - let state_handler = HandleStateMock { state_map: Default::default() }; - state_handler.initialize_shard(shard)?; - Ok(state_handler) - } -} - -impl HandleState for HandleStateMock { - type WriteLockPayload = HashMap; - type StateT = StfState; - type HashType = H256; - - fn initialize_shard(&self, shard: ShardIdentifier) -> Result { - self.reset(StfState::default(), &shard) - } - - fn migrate_shard(&self, new_shard: ShardIdentifier) -> Result { - let old_shard = *self.state_map.read().unwrap().keys().next().unwrap(); - let (state, _) = self.load_cloned(&old_shard)?; - self.reset(state, &new_shard) - } - - fn execute_on_current(&self, shard: &ShardIdentifier, executing_function: E) -> Result - where - E: FnOnce(&Self::StateT, Self::HashType) -> R, - { - self.state_map - .read() - .unwrap() - .get(shard) - .map(|state| executing_function(state, state.hash())) - .ok_or_else(|| Error::Other(format!("shard is not initialized {:?}", shard).into())) - } - - fn load_cloned(&self, shard: &ShardIdentifier) -> Result<(Self::StateT, Self::HashType)> { - self.state_map - .read() - .unwrap() - .get(shard) - .cloned() - .map(|s| { - let state_hash = s.hash(); - (s, state_hash) - }) - .ok_or_else(|| Error::Other(format!("shard is not initialized {:?}", shard).into())) - } - - fn load_for_mutation( - &self, - shard: &ShardIdentifier, - ) -> Result<(RwLockWriteGuard<'_, Self::WriteLockPayload>, StfState)> { - let (initialized_state, _) = self.load_cloned(shard)?; - let write_lock = self.state_map.write().unwrap(); - Ok((write_lock, initialized_state)) - } - - fn write_after_mutation( - &self, - state: StfState, - mut state_lock: RwLockWriteGuard<'_, Self::WriteLockPayload>, - shard: &ShardIdentifier, - ) -> Result { - state_lock.insert(*shard, state.clone()); - Ok(state.hash()) - } - - fn reset(&self, state: Self::StateT, shard: &ShardIdentifier) -> Result { - let write_lock = self.state_map.write().unwrap(); - self.write_after_mutation(state, write_lock, shard) - } -} - -impl QueryShardState for HandleStateMock { - fn shard_exists(&self, shard: &ShardIdentifier) -> Result { - let state_map_lock = self.state_map.read().map_err(|_| Error::LockPoisoning)?; - Ok(state_map_lock.get(shard).is_some()) - } - - fn list_shards(&self) -> Result> { - Ok(self.state_map.read().unwrap().iter().map(|(k, _)| *k).collect()) - } -} - -// Since the mock itself has quite a bit of complexity, we also have tests for the mock. -#[cfg(feature = "sgx")] -pub mod tests { - - use super::*; - use crate::mock::stf_mock::StfMock; - use codec::{Decode, Encode}; - use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesTrait, SgxExternalitiesType}; - use itp_stf_interface::InitState; - use itp_types::ShardIdentifier; - use sp_core::crypto::AccountId32; - - pub fn initialized_shards_list_is_empty() { - let state_handler = HandleStateMock::default(); - assert!(state_handler.list_shards().unwrap().is_empty()); - } - - pub fn shard_exists_after_inserting() { - let state_handler = HandleStateMock::default(); - let shard = ShardIdentifier::default(); - state_handler.initialize_shard(shard).unwrap(); - - assert!(state_handler.load_cloned(&shard).is_ok()); - assert!(state_handler.shard_exists(&shard).unwrap()); - } - - pub fn from_shard_works() { - let shard = ShardIdentifier::default(); - let state_handler = HandleStateMock::from_shard(shard).unwrap(); - - assert!(state_handler.load_cloned(&shard).is_ok()); - assert!(state_handler.shard_exists(&shard).unwrap()); - } - - pub fn initialize_creates_default_state() { - let state_handler = HandleStateMock::default(); - let shard = ShardIdentifier::default(); - state_handler.initialize_shard(shard).unwrap(); - - let loaded_state_result = state_handler.load_cloned(&shard); - - assert!(loaded_state_result.is_ok()); - } - - pub fn load_mutate_and_write_works() { - let state_handler = HandleStateMock::default(); - let shard = ShardIdentifier::default(); - state_handler.initialize_shard(shard).unwrap(); - - let (lock, mut state) = state_handler.load_for_mutation(&shard).unwrap(); - - let (key, value) = ("my_key", "my_value"); - state.insert(key.encode(), value.encode()); - - state_handler.write_after_mutation(state, lock, &shard).unwrap(); - - let (updated_state, _) = state_handler.load_cloned(&shard).unwrap(); - - let inserted_value = - updated_state.get(key.encode().as_slice()).expect("value for key should exist"); - assert_eq!(*inserted_value, value.encode()); - } - - pub fn ensure_subsequent_state_loads_have_same_hash() { - let state_handler = HandleStateMock::default(); - let shard = ShardIdentifier::default(); - state_handler.initialize_shard(shard).unwrap(); - - let (lock, _) = state_handler.load_for_mutation(&shard).unwrap(); - let initial_state = StfMock::init_state(AccountId32::new([0u8; 32])); - let state_hash_before_execution = initial_state.hash(); - state_handler.write_after_mutation(initial_state, lock, &shard).unwrap(); - - let (_, loaded_state_hash) = state_handler.load_cloned(&shard).unwrap(); - - assert_eq!(state_hash_before_execution, loaded_state_hash); - } - - pub fn ensure_encode_and_encrypt_does_not_affect_state_hash() { - let state = StfMock::init_state(AccountId32::new([0u8; 32])); - let state_hash_before_execution = state.hash(); - - let encoded_state = state.state.encode(); - let decoded_state: SgxExternalitiesType = decode(encoded_state); - let decoded_state_hash = SgxExternalities::new(decoded_state).hash(); - - assert_eq!(state_hash_before_execution, decoded_state_hash); - } - - pub fn migrate_shard_works() { - let state_handler = HandleStateMock::default(); - let old_shard = ShardIdentifier::default(); - let bytes = hex::decode("91de6f606be264f089b155256385470f5395969386894ffba38775442f508ee2") - .unwrap(); - let new_shard = ShardIdentifier::from_slice(&bytes); - state_handler.initialize_shard(old_shard).unwrap(); - - let (lock, mut state) = state_handler.load_for_mutation(&old_shard).unwrap(); - let (key, value) = ("my_key", "my_value"); - state.insert(key.encode(), value.encode()); - state_handler.write_after_mutation(state, lock, &old_shard).unwrap(); - - state_handler.migrate_shard(new_shard).unwrap(); - let (new_state, _) = state_handler.load_cloned(&new_shard).unwrap(); - let inserted_value = - new_state.get(key.encode().as_slice()).expect("value for key should exist"); - assert_eq!(*inserted_value, value.encode()); - } - - fn decode(encoded: Vec) -> T { - T::decode(&mut encoded.as_slice()).unwrap() - } -} diff --git a/tee-worker/identity/core-primitives/test/src/mock/metrics_ocall_mock.rs b/tee-worker/identity/core-primitives/test/src/mock/metrics_ocall_mock.rs deleted file mode 100644 index 14cd8e67c5..0000000000 --- a/tee-worker/identity/core-primitives/test/src/mock/metrics_ocall_mock.rs +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use codec::Encode; -use itp_ocall_api::EnclaveMetricsOCallApi; -use sgx_types::SgxResult; -use std::vec::Vec; - -/// Metrics o-call mock. -#[derive(Default)] -pub struct MetricsOCallMock { - metric_updates: RwLock>>, -} - -impl Clone for MetricsOCallMock { - fn clone(&self) -> Self { - MetricsOCallMock { - metric_updates: RwLock::new(self.metric_updates.read().unwrap().clone()), - } - } -} - -impl MetricsOCallMock { - pub fn get_metrics_updates(&self) -> Vec> { - self.metric_updates.read().unwrap().clone() - } -} - -impl EnclaveMetricsOCallApi for MetricsOCallMock { - fn update_metric(&self, metric: Metric) -> SgxResult<()> { - self.metric_updates.write().unwrap().push(metric.encode()); - Ok(()) - } -} diff --git a/tee-worker/identity/core-primitives/test/src/mock/mod.rs b/tee-worker/identity/core-primitives/test/src/mock/mod.rs deleted file mode 100644 index a59c988a59..0000000000 --- a/tee-worker/identity/core-primitives/test/src/mock/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod handle_state_mock; -pub mod metrics_ocall_mock; -pub mod onchain_mock; -pub mod shielding_crypto_mock; -pub mod sidechain_ocall_api_mock; -pub mod stf_mock; diff --git a/tee-worker/identity/core-primitives/test/src/mock/shielding_crypto_mock.rs b/tee-worker/identity/core-primitives/test/src/mock/shielding_crypto_mock.rs deleted file mode 100644 index 0006ba1245..0000000000 --- a/tee-worker/identity/core-primitives/test/src/mock/shielding_crypto_mock.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 itp_sgx_crypto::{ - ed25519_derivation::DeriveEd25519, ShieldingCryptoDecrypt, ShieldingCryptoEncrypt, -}; -use sgx_crypto_helper::{rsa3072::Rsa3072KeyPair, RsaKeyPair}; -use sp_core::ed25519::Pair as Ed25519Pair; -use std::vec::Vec; - -#[derive(Clone)] -pub struct ShieldingCryptoMock { - key: Rsa3072KeyPair, -} - -impl Default for ShieldingCryptoMock { - fn default() -> Self { - ShieldingCryptoMock { - key: Rsa3072KeyPair::new().expect("default RSA3072 key for shielding key mock"), - } - } -} - -impl ShieldingCryptoEncrypt for ShieldingCryptoMock { - type Error = itp_sgx_crypto::Error; - - fn encrypt(&self, data: &[u8]) -> Result, Self::Error> { - self.key.encrypt(data) - } -} - -impl ShieldingCryptoDecrypt for ShieldingCryptoMock { - type Error = itp_sgx_crypto::Error; - - fn decrypt(&self, data: &[u8]) -> Result, Self::Error> { - self.key.decrypt(data) - } -} - -impl DeriveEd25519 for ShieldingCryptoMock { - fn derive_ed25519(&self) -> Result { - self.key.derive_ed25519() - } -} diff --git a/tee-worker/identity/core-primitives/time-utils/Cargo.toml b/tee-worker/identity/core-primitives/time-utils/Cargo.toml deleted file mode 100644 index cf8a8d2285..0000000000 --- a/tee-worker/identity/core-primitives/time-utils/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "itp-time-utils" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -chrono = { version = "0.4.19", features = ["alloc"], optional = true } - -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - -[features] -default = ["std"] -std = [ - "chrono", -] -sgx = [ - "sgx_tstd", - "chrono_sgx", -] diff --git a/tee-worker/identity/core-primitives/time-utils/src/lib.rs b/tee-worker/identity/core-primitives/time-utils/src/lib.rs deleted file mode 100644 index 51ac211d72..0000000000 --- a/tee-worker/identity/core-primitives/time-utils/src/lib.rs +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ -//! General time utility functions. -#![feature(trait_alias)] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate chrono_sgx as chrono; - -use chrono::{offset::FixedOffset, DateTime, Utc}; -use std::{ - string::String, - time::{Duration, SystemTime}, -}; - -/// Returns the current timestamp based on the unix epoch in seconds. -pub fn now_as_secs() -> u64 { - duration_now().as_secs() -} - -/// Returns current duration since unix epoch in millis as u64. -pub fn now_as_millis() -> u64 { - duration_now().as_millis() as u64 -} - -pub fn now_as_iso8601() -> String { - let date_time: DateTime = SystemTime::now().into(); - date_time.to_rfc3339() -} - -pub fn from_iso8601(datetime_str: &str) -> Option> { - DateTime::parse_from_rfc3339(datetime_str).ok() -} - -/// Returns the current timestamp based on the unix epoch in nanoseconds. -pub fn now_as_nanos() -> u128 { - duration_now().as_nanos() -} - -/// Calculates the remaining time from now to `until`. -pub fn remaining_time(until: Duration) -> Option { - duration_difference(duration_now(), until) -} - -/// Calculate the difference in duration between `from` and `to`. -/// Returns `None` if `to` < `from`. -pub fn duration_difference(from: Duration, to: Duration) -> Option { - to.checked_sub(from) -} - -/// Returns current duration since unix epoch with SystemTime::now(). -/// Note: subsequent calls are not guaranteed to be monotonic. -/// (https://doc.rust-lang.org/std/time/struct.SystemTime.html) -pub fn duration_now() -> Duration { - let now = SystemTime::now(); - now.duration_since(SystemTime::UNIX_EPOCH).unwrap_or_else(|e| { - panic!("Current time {:?} is before unix epoch. Something is wrong: {:?}", now, e) - }) -} diff --git a/tee-worker/identity/core-primitives/top-pool-author/Cargo.toml b/tee-worker/identity/core-primitives/top-pool-author/Cargo.toml index 6eaeb07ec3..8932b8a999 100644 --- a/tee-worker/identity/core-primitives/top-pool-author/Cargo.toml +++ b/tee-worker/identity/core-primitives/top-pool-author/Cargo.toml @@ -1,50 +1,41 @@ [package] -name = "itp-top-pool-author" +name = "id-itp-top-pool-author" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, optional = true } -# local dependencies -itp-enclave-metrics = { path = "../enclave-metrics", default-features = false } -itp-ocall-api = { path = "../ocall-api", default-features = false } -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../stf-state-handler", default-features = false } -itp-test = { path = "../test", default-features = false, optional = true } -itp-top-pool = { path = "../top-pool", default-features = false } -itp-types = { path = "../types", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-test = { workspace = true, optional = true } +itp-top-pool = { package = "id-itp-top-pool", path = "../top-pool", default-features = false } +itp-types = { workspace = true } +itp-utils = { workspace = true } +litentry-primitives = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } +jsonrpc-core = { workspace = true, optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +lazy_static = { workspace = true, optional = true } +log = { workspace = true } -# no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -lazy_static = { version = "1.1.0", optional = true } - -# litentry -itp-utils = { path = "../utils", default-features = false } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } [dev-dependencies] -futures = { version = "0.3" } -itp-sgx-crypto = { path = "../sgx/crypto", features = ["mocks"] } -itp-test = { path = "../test" } -itp-top-pool = { path = "../top-pool", features = ["mocks"] } -sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", package = "sgx_crypto_helper", default-features = false } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - +futures = { workspace = true } +itp-sgx-crypto = { workspace = true, features = ["mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool = { package = "id-itp-top-pool", path = "../top-pool", features = ["std", "mocks"] } +sgx_crypto_helper = { workspace = true } +sp-keyring = { workspace = true } [features] default = ["std"] @@ -57,7 +48,6 @@ std = [ "itp-types/std", "jsonrpc-core", "log/std", - # litentry "litentry-primitives/std", "itp-utils/std", ] @@ -68,7 +58,6 @@ sgx = [ "itp-sgx-crypto/sgx", "itp-stf-state-handler/sgx", "itp-top-pool/sgx", - # litentry "litentry-primitives/sgx", ] test = ["itp-test/sgx", "itp-top-pool/mocks"] diff --git a/tee-worker/identity/core-primitives/top-pool/Cargo.toml b/tee-worker/identity/core-primitives/top-pool/Cargo.toml index c2cb99e2ea..57a54b116f 100644 --- a/tee-worker/identity/core-primitives/top-pool/Cargo.toml +++ b/tee-worker/identity/core-primitives/top-pool/Cargo.toml @@ -1,43 +1,36 @@ [package] -name = "itp-top-pool" +name = "id-itp-top-pool" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread", "untrusted_time"] } +sgx_tstd = { workspace = true, features = ["net", "thread", "untrusted_time"], optional = true } -# local dependencies -itc-direct-rpc-server = { path = "../../core/direct-rpc-server", default-features = false } -itp-stf-primitives = { path = "../stf-primitives", default-features = false } -itp-types = { path = "../types", default-features = false } -its-primitives = { path = "../../sidechain/primitives", default-features = false } +itc-direct-rpc-server = { package = "id-itc-direct-rpc-server", path = "../../core/direct-rpc-server", default-features = false } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } +its-primitives = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -linked-hash-map_sgx = { package = "linked-hash-map", git = "https://github.com/mesalock-linux/linked-hash-map-sgx", optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } +linked-hash-map_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } -linked-hash-map = { version = "0.5.2", optional = true } +jsonrpc-core = { workspace = true, optional = true } +linked-hash-map = { workspace = true, optional = true } -# no-std compatible libraries -byteorder = { version = "1.4.2", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = { version = "0.99.5" } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +byteorder = { workspace = true } +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } -# dev dependencies (for tests) [dev-dependencies] -parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] } -itp-test = { path = "../test", default-features = false } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +parity-util-mem = { workspace = true, features = ["primitive-types"] } +itp-test = { workspace = true } +serde = { workspace = true } +sp-application-crypto = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/core-primitives/top-pool/src/pool.rs b/tee-worker/identity/core-primitives/top-pool/src/pool.rs index 9dd5d71af7..c8a432cc9c 100644 --- a/tee-worker/identity/core-primitives/top-pool/src/pool.rs +++ b/tee-worker/identity/core-primitives/top-pool/src/pool.rs @@ -544,10 +544,10 @@ pub mod tests { #[derive(Clone, Debug, Default)] struct TestApi { - delay: Arc>>>, - invalidate: Arc>>, - clear_requirements: Arc>>, - add_requirements: Arc>>, + _delay: Arc>>>, + _invalidate: Arc>>, + _clear_requirements: Arc>>, + _add_requirements: Arc>>, } impl ChainApi for TestApi { diff --git a/tee-worker/identity/core-primitives/types/Cargo.toml b/tee-worker/identity/core-primitives/types/Cargo.toml deleted file mode 100644 index ff6863e7a0..0000000000 --- a/tee-worker/identity/core-primitives/types/Cargo.toml +++ /dev/null @@ -1,52 +0,0 @@ -[package] -name = "itp-types" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -homepage = 'https://litentry.com/' -repository = 'https://github.com/litentry/litentry-parachain' -license = "Apache-2.0" -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } - -# local dependencies -itp-sgx-crypto = { path = "../sgx/crypto", default-features = false } -itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-utils = { path = "../../core-primitives/utils", default-features = false } - -# scs -substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } - -# substrate-deps -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "itp-sgx-crypto/std", - "itp-sgx-runtime-primitives/std", - "itp-stf-primitives/std", - "itp-utils/std", - "substrate-api-client/std", - # substrate - "frame-system/std", - "pallet-balances/std", - "serde/std", - "sp-std/std", - "sp-core/std", - "sp-runtime/std", - # litentry - "litentry-primitives/std", -] -test = [] diff --git a/tee-worker/identity/core-primitives/types/src/storage.rs b/tee-worker/identity/core-primitives/types/src/storage.rs deleted file mode 100644 index b30f1d6f21..0000000000 --- a/tee-worker/identity/core-primitives/types/src/storage.rs +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 codec::{Decode, Encode}; -use sp_std::prelude::Vec; - -#[derive(Default, Clone, Encode, Decode)] -pub struct StorageEntry { - pub key: Vec, - pub value: Option, - pub proof: Option>>, -} - -/// Contains private fields. We don't expose a public constructor. Hence, the only way -/// to get a `StorageEntryVerified` is via the `VerifyStorageProof` trait. -#[derive(Default, Clone, Encode, Decode)] -pub struct StorageEntryVerified { - pub key: Vec, - pub value: Option, -} - -#[cfg(feature = "test")] -impl StorageEntryVerified { - pub fn new(key: Vec, value: Option) -> Self { - Self { key, value } - } -} - -impl StorageEntryVerified { - pub fn key(&self) -> &[u8] { - &self.key - } - - pub fn value(&self) -> &Option { - &self.value - } - - /// Without accessing the field directly but with getters only, we cannot partially - /// own the struct. So we can't do: `hashmap.insert(self.key(), self.value())` if the getters - /// consumed the `self`, which is needed to return owned values. Hence, we supply this method, - /// to consume `self` and be able to use the values individually. - pub fn into_tuple(self) -> (Vec, Option) { - (self.key, self.value) - } -} diff --git a/tee-worker/identity/core-primitives/utils/src/buffer.rs b/tee-worker/identity/core-primitives/utils/src/buffer.rs deleted file mode 100644 index 89d02ccc0f..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/buffer.rs +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Buffer utility functions. - -use alloc::vec::Vec; - -/// Fills a given buffer with data and the left over buffer space with white spaces. -/// Throw an error if the buffer size is not enough to hold `data`, -/// return the length of `data` otherwise. -pub fn write_slice_and_whitespace_pad( - writable: &mut [u8], - data: Vec, -) -> Result { - if data.len() > writable.len() { - return Err(BufferError::InsufficientBufferSize { - actual: writable.len(), - required: data.len(), - }) - } - let (left, right) = writable.split_at_mut(data.len()); - left.clone_from_slice(&data); - // fill the right side with whitespace - right.iter_mut().for_each(|x| *x = 0x20); - Ok(data.len()) -} - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum BufferError { - InsufficientBufferSize { actual: usize, required: usize }, -} - -#[cfg(test)] -mod tests { - use super::*; - use alloc::vec; - - #[test] - fn write_slice_and_whitespace_pad_works() { - let mut writable = vec![0; 32]; - let data = vec![1; 30]; - assert_eq!(write_slice_and_whitespace_pad(&mut writable, data), Ok(30)); - assert_eq!(&writable[..30], vec![1; 30]); - assert_eq!(&writable[30..], vec![0x20; 2]); - } - - #[test] - fn write_slice_and_whitespace_pad_returns_error_if_buffer_too_small() { - let mut writable = vec![0; 32]; - let data = vec![1; 33]; - assert!(write_slice_and_whitespace_pad(&mut writable, data).is_err()); - } -} diff --git a/tee-worker/identity/core-primitives/utils/src/error.rs b/tee-worker/identity/core-primitives/utils/src/error.rs deleted file mode 100644 index 5ca7508d26..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/error.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 alloc::string::String; - -pub type Result = core::result::Result; - -#[derive(Debug)] -pub enum Error { - Hex(hex::FromHexError), - Codec(codec::Error), - Other(String), -} diff --git a/tee-worker/identity/core-primitives/utils/src/hex.rs b/tee-worker/identity/core-primitives/utils/src/hex.rs deleted file mode 100644 index 3b6ff8a8a8..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/hex.rs +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Hex encoding utility functions. - -// Todo: merge with hex_display - -use crate::error::{Error, Result}; -use alloc::string::String; -use codec::{Decode, Encode}; -use litentry_hex_utils::{decode_hex, hex_encode}; - -/// Trait to encode a given value to a hex string, prefixed with "0x". -pub trait ToHexPrefixed { - fn to_hex(&self) -> String; -} - -impl ToHexPrefixed for T { - fn to_hex(&self) -> String { - hex_encode(&self.encode()) - } -} - -/// Trait to decode a hex string to a given output. -pub trait FromHexPrefixed { - type Output; - - fn from_hex(msg: &str) -> Result; -} - -impl FromHexPrefixed for T { - type Output = T; - - fn from_hex(msg: &str) -> Result { - let byte_array = decode_hex(msg).map_err(Error::Hex)?; - Decode::decode(&mut byte_array.as_slice()).map_err(Error::Codec) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use alloc::string::ToString; - - #[test] - fn hex_encode_decode_works_empty_input_for_decode() { - let data = String::new(); - - let decoded_data = decode_hex(data).unwrap(); - - assert!(decoded_data.is_empty()); - } - - #[test] - fn to_hex_from_hex_works() { - let data = "Hello World!".to_string(); - - let hex_encoded_data = data.to_hex(); - let decoded_data = String::from_hex(&hex_encoded_data).unwrap(); - - assert_eq!(data, decoded_data); - } -} diff --git a/tee-worker/identity/core-primitives/utils/src/hex_display.rs b/tee-worker/identity/core-primitives/utils/src/hex_display.rs deleted file mode 100644 index f0525b4e2f..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/hex_display.rs +++ /dev/null @@ -1,96 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed 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. - -//! Wrapper type for byte collections that outputs hex. -//! -//! Copied from sp-core and made purely no-std. - -/// Simple wrapper to display hex representation of bytes. -pub struct HexDisplay<'a>(&'a [u8]); - -impl<'a> HexDisplay<'a> { - /// Create new instance that will display `d` as a hex string when displayed. - pub fn from(d: &'a R) -> Self { - HexDisplay(d.as_bytes_ref()) - } -} - -impl<'a> core::fmt::Display for HexDisplay<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { - if self.0.len() < 1027 { - for byte in self.0 { - f.write_fmt(format_args!("{:02x}", byte))?; - } - } else { - for byte in &self.0[0..512] { - f.write_fmt(format_args!("{:02x}", byte))?; - } - f.write_str("...")?; - for byte in &self.0[self.0.len() - 512..] { - f.write_fmt(format_args!("{:02x}", byte))?; - } - } - Ok(()) - } -} - -impl<'a> core::fmt::Debug for HexDisplay<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { - for byte in self.0 { - f.write_fmt(format_args!("{:02x}", byte))?; - } - Ok(()) - } -} - -/// Simple trait to transform various types to `&[u8]` -pub trait AsBytesRef { - /// Transform `self` into `&[u8]`. - fn as_bytes_ref(&self) -> &[u8]; -} - -impl AsBytesRef for &[u8] { - fn as_bytes_ref(&self) -> &[u8] { - self - } -} - -impl AsBytesRef for [u8] { - fn as_bytes_ref(&self) -> &[u8] { - self - } -} - -impl AsBytesRef for alloc::vec::Vec { - fn as_bytes_ref(&self) -> &[u8] { - self - } -} - -macro_rules! impl_non_endians { - ( $( $t:ty ),* ) => { $( - impl AsBytesRef for $t { - fn as_bytes_ref(&self) -> &[u8] { &self[..] } - } - )* } -} - -impl_non_endians!( - [u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8], [u8; 10], [u8; 12], - [u8; 14], [u8; 16], [u8; 20], [u8; 24], [u8; 28], [u8; 32], [u8; 40], [u8; 48], [u8; 56], - [u8; 64], [u8; 65], [u8; 80], [u8; 96], [u8; 112], [u8; 128] -); diff --git a/tee-worker/identity/core-primitives/utils/src/lib.rs b/tee-worker/identity/core-primitives/utils/src/lib.rs deleted file mode 100644 index 297ff5090e..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/lib.rs +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! General utility functions. - -#![no_std] - -extern crate alloc; - -pub mod buffer; -pub mod error; -pub mod hex; -pub mod hex_display; -pub mod stringify; - -// Public re-exports. -pub use self::{ - buffer::write_slice_and_whitespace_pad, - hex::{FromHexPrefixed, ToHexPrefixed}, -}; diff --git a/tee-worker/identity/core-primitives/utils/src/stringify.rs b/tee-worker/identity/core-primitives/utils/src/stringify.rs deleted file mode 100644 index e514fdbecb..0000000000 --- a/tee-worker/identity/core-primitives/utils/src/stringify.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Utility methods to stringify certain types that don't have a working -//! `Debug` implementation on `sgx`. - -use crate::hex_display::{AsBytesRef, HexDisplay}; -use alloc::{format, string::String}; -use codec::Encode; - -/// Convert a sp_core public type to string. -pub fn public_to_string(t: &T) -> String { - format!("{}", HexDisplay::from(t)) -} - -pub fn account_id_to_string(account: &AccountId) -> String { - format!("0x{}", HexDisplay::from(&account.encode())) -} - -pub fn account_id_to_string_without_prefix(account: &AccountId) -> String { - format!("{}", HexDisplay::from(&account.encode())) -} diff --git a/tee-worker/identity/core/direct-rpc-client/Cargo.toml b/tee-worker/identity/core/direct-rpc-client/Cargo.toml index 1d41105ec3..3eb5ea6f6d 100644 --- a/tee-worker/identity/core/direct-rpc-client/Cargo.toml +++ b/tee-worker/identity/core/direct-rpc-client/Cargo.toml @@ -1,30 +1,26 @@ [package] -name = "itc-direct-rpc-client" +name = "id-itc-direct-rpc-client" version = "0.1.0" authors = ['Trust Computing GmbH '] edition = "2021" [dependencies] -# sgx dependencies -rustls_sgx = { package = "rustls", optional = true, git = "https://github.com/mesalock-linux/rustls", tag = "sgx_1.1.3", features = ["dangerous_configuration"] } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -tungstenite_sgx = { package = "tungstenite", optional = true, git = "https://github.com/integritee-network/tungstenite-rs-sgx", branch = "sgx-experimental", features = ["rustls-tls-webpki-roots"] } -webpki_sgx = { package = "webpki", optional = true, git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } +rustls_sgx = { workspace = true, features = ["dangerous_configuration"], optional = true } +sgx_tstd = { workspace = true, optional = true } +tungstenite_sgx = { workspace = true, optional = true } +webpki_sgx = { workspace = true, optional = true } -# no-std dependencies -log = { version = "0.4", default-features = false } -serde_json = { version = "1.0", default-features = false } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } +log = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } -# std dependencies -rustls = { version = "0.19", optional = true, features = ["dangerous_configuration"] } -tungstenite = { version = "0.15.0", optional = true, features = ["rustls-tls-webpki-roots"] } -webpki = { version = "0.21", optional = true } +rustls = { workspace = true, features = ["dangerous_configuration"], optional = true } +tungstenite = { workspace = true, features = ["rustls-tls-webpki-roots"], optional = true } +webpki = { workspace = true, optional = true } -# local dependencies -itp-rpc = { path = "../../core-primitives/rpc", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } -itp-utils = { path = "../../core-primitives/utils", default-features = false } +itp-rpc = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/core/direct-rpc-server/Cargo.toml b/tee-worker/identity/core/direct-rpc-server/Cargo.toml index ca46e22564..2138b329e6 100644 --- a/tee-worker/identity/core/direct-rpc-server/Cargo.toml +++ b/tee-worker/identity/core/direct-rpc-server/Cargo.toml @@ -1,32 +1,26 @@ [package] -name = "itc-direct-rpc-server" +name = "id-itc-direct-rpc-server" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no-std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +serde_json = { workspace = true } +sp-runtime = { workspace = true } -# local -itc-tls-websocket-server = { path = "../tls-websocket-server", default-features = false } -itp-rpc = { path = "../../core-primitives/rpc", default-features = false } -itp-types = { default-features = false, path = "../../core-primitives/types" } -itp-utils = { default-features = false, path = "../../core-primitives/utils" } +itc-tls-websocket-server = { workspace = true } +itp-rpc = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } -# sgx enabled external libraries -jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std_v18", default-features = false, optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -jsonrpc-core = { version = "18", optional = true } -thiserror = { version = "1.0", optional = true } +jsonrpc-core = { workspace = true, optional = true } +jsonrpc-core_sgx = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } [features] default = ["std"] diff --git a/tee-worker/identity/core/offchain-worker-executor/Cargo.toml b/tee-worker/identity/core/offchain-worker-executor/Cargo.toml index a1acb1f113..a333fc7838 100644 --- a/tee-worker/identity/core/offchain-worker-executor/Cargo.toml +++ b/tee-worker/identity/core/offchain-worker-executor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "itc-offchain-worker-executor" +name = "id-itc-offchain-worker-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" @@ -7,43 +7,34 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sgx_tstd = { workspace = true, optional = true } -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } +itc-parentchain-light-client = { workspace = true } +itp-extrinsics-factory = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../core-primitives/stf-executor", default-features = false } +itp-stf-interface = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } -# local dependencies -itc-parentchain-light-client = { path = "../../core/parentchain/light-client", default-features = false } -itp-extrinsics-factory = { path = "../../core-primitives/extrinsics-factory", default-features = false } -itp-stf-executor = { path = "../../core-primitives/stf-executor", default-features = false } -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 } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } - -# Substrate dependencies -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# no-std compatible libraries -log = { version = "0.4", default-features = false } +sp-runtime = { workspace = true } [dev-dependencies] -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -itc-parentchain-light-client = { path = "../../core/parentchain/light-client", features = ["mocks"] } -itp-extrinsics-factory = { path = "../../core-primitives/extrinsics-factory", features = ["mocks"] } -itp-stf-executor = { path = "../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../core-primitives/test" } -itp-top-pool-author = { path = "../../core-primitives/top-pool-author", features = ["mocks"] } -itp-stf-interface = { path = "../../core-primitives/stf-interface", features = ["mocks"] } -itp-sgx-externalities = { path = "../../core-primitives/substrate-sgx/externalities" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true, features = ["std"] } +itc-parentchain-light-client = { workspace = true, features = ["std", "mocks"] } +itp-extrinsics-factory = { workspace = true, features = ["std", "mocks"] } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../core-primitives/stf-executor", features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../core-primitives/top-pool-author", features = ["std", "mocks"] } +itp-stf-interface = { workspace = true, features = ["std", "mocks"] } +itp-sgx-externalities = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } [features] default = ["std"] diff --git a/tee-worker/identity/core/parentchain/block-import-dispatcher/Cargo.toml b/tee-worker/identity/core/parentchain/block-import-dispatcher/Cargo.toml index 66f23ad2c8..e75591f657 100644 --- a/tee-worker/identity/core/parentchain/block-import-dispatcher/Cargo.toml +++ b/tee-worker/identity/core/parentchain/block-import-dispatcher/Cargo.toml @@ -1,48 +1,36 @@ [package] -name = "itc-parentchain-block-import-dispatcher" +name = "id-itc-parentchain-block-import-dispatcher" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } -# local dependencies -itc-parentchain-block-importer = { path = "../block-importer", default-features = false } -itp-import-queue = { path = "../../../core-primitives/import-queue", default-features = false } +itc-parentchain-block-importer = { package = "id-itc-parentchain-block-importer", path = "../block-importer", default-features = false } +itp-import-queue = { workspace = true } -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# crates.io std-only compatible libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries -log = { version = "0.4", default-features = false } +log = { workspace = true } [dev-dependencies] -itc-parentchain-block-importer = { path = "../block-importer", features = ["mocks"] } +itc-parentchain-block-importer = { package = "id-itc-parentchain-block-importer", path = "../block-importer", features = ["mocks"] } [features] default = ["std"] std = [ - # local "itc-parentchain-block-importer/std", "itp-import-queue/std", - # no-std compatible libraries "log/std", - # std-only compatible libraries "thiserror", ] sgx = [ - # sgx "sgx_tstd", - # local "itc-parentchain-block-importer/sgx", "itp-import-queue/sgx", - # sgx enabled external libraries "thiserror_sgx", ] diff --git a/tee-worker/identity/core/parentchain/block-importer/Cargo.toml b/tee-worker/identity/core/parentchain/block-importer/Cargo.toml index 9028d78799..5eabe65488 100644 --- a/tee-worker/identity/core/parentchain/block-importer/Cargo.toml +++ b/tee-worker/identity/core/parentchain/block-importer/Cargo.toml @@ -1,42 +1,33 @@ [package] -name = "itc-parentchain-block-importer" +name = "id-itc-parentchain-block-importer" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } - -# local dependencies -ita-stf = { path = "../../../app-libs/stf", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../indirect-calls-executor", default-features = false } -itc-parentchain-light-client = { path = "../light-client", default-features = false } -itp-enclave-metrics = { path = "../../../core-primitives/enclave-metrics", default-features = false } -itp-extrinsics-factory = { path = "../../../core-primitives/extrinsics-factory", default-features = false } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", default-features = false } -itp-stf-interface = { path = "../../../core-primitives/stf-interface", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } - -# sgx enabled external libraries -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# crates.io std-only compatible external libraries (make sure these versions match with the sgx-enabled ones above) -thiserror = { version = "1.0", optional = true } - -# crates.io no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } + +ita-stf = { package = "id-ita-stf", path = "../../../app-libs/stf", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "id-itc-parentchain-indirect-calls-executor", path = "../indirect-calls-executor", default-features = false } +itc-parentchain-light-client = { workspace = true } +itp-enclave-metrics = { workspace = true } +itp-extrinsics-factory = { workspace = true } +itp-ocall-api = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } +itp-stf-interface = { workspace = true } +itp-types = { workspace = true } + +thiserror = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } + +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-runtime = { workspace = true } [features] default = ["std"] std = [ - # local "ita-stf/std", "itc-parentchain-indirect-calls-executor/std", "itc-parentchain-light-client/std", @@ -45,25 +36,20 @@ std = [ "itp-stf-executor/std", "itp-stf-interface/std", "itp-types/std", - # no-std compatible libraries "codec/std", "log/std", "sp-runtime/std", - # std compatible external "thiserror", "itp-ocall-api/std", ] sgx = [ - # sgx "sgx_tstd", - # local "ita-stf/sgx", "itc-parentchain-indirect-calls-executor/sgx", "itc-parentchain-light-client/sgx", "itp-enclave-metrics/sgx", "itp-extrinsics-factory/sgx", "itp-stf-executor/sgx", - # sgx enabled external libraries "thiserror_sgx", ] diff --git a/tee-worker/identity/core/parentchain/indirect-calls-executor/Cargo.toml b/tee-worker/identity/core/parentchain/indirect-calls-executor/Cargo.toml index a41305b27e..b77dbeac3d 100644 --- a/tee-worker/identity/core/parentchain/indirect-calls-executor/Cargo.toml +++ b/tee-worker/identity/core/parentchain/indirect-calls-executor/Cargo.toml @@ -1,63 +1,57 @@ [package] -name = "itc-parentchain-indirect-calls-executor" +name = "id-itc-parentchain-indirect-calls-executor" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_tstd = { workspace = true, optional = true } +sgx_types = { workspace = true } -# local dependencies -itp-api-client-types = { path = "../../../core-primitives/node-api/api-client-types", default-features = false } -itp-enclave-metrics = { path = "../../../core-primitives/enclave-metrics", default-features = false } -itp-node-api = { path = "../../../core-primitives/node-api", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", default-features = false } -itp-stf-primitives = { path = "../../../core-primitives/stf-primitives", default-features = false } -itp-test = { path = "../../../core-primitives/test", default-features = false } -itp-top-pool-author = { path = "../../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } +itp-api-client-types = { workspace = true } +itp-enclave-metrics = { workspace = true } +itp-node-api = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-runtime-primitives = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } +itp-stf-primitives = { workspace = true } +itp-test = { workspace = true } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } -# sgx enabled external libraries -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +futures_sgx = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -futures = { version = "0.3.8", optional = true } -thiserror = { version = "1.0", optional = true } +futures = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } -# no-std compatible libraries -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } +bs58 = { version = "0.4.0", default-features = false, features = ["alloc"] } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } -# substrate dep -binary-merkle-tree = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# litentry -litentry-primitives = { path = "../../../litentry/primitives", default-features = false } +binary-merkle-tree = { workspace = true } +litentry-primitives = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } [dev-dependencies] -env_logger = "0.9.0" -itp-node-api = { path = "../../../core-primitives/node-api", features = ["mocks"] } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", features = ["mocks"] } -itp-stf-executor = { path = "../../../core-primitives/stf-executor", features = ["mocks"] } -itp-test = { path = "../../../core-primitives/test" } -itp-top-pool-author = { path = "../../../core-primitives/top-pool-author", features = ["mocks"] } -itc-parentchain-test = { path = "../../../core/parentchain/test" } -ita-parentchain-interface = { path = "../../../app-libs/parentchain-interface" } -lc-evm-dynamic-assertions = { path = "../../../litentry/core/evm-dynamic-assertions" } +env_logger = { workspace = true } +itp-node-api = { workspace = true, features = ["std", "mocks"] } +itp-sgx-crypto = { workspace = true, features = ["std", "mocks"] } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../core-primitives/stf-executor", features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../../core-primitives/top-pool-author", features = ["std", "mocks"] } +itc-parentchain-test = { workspace = true, features = ["std"] } [features] default = ["std"] std = [ + "bs58/std", "codec/std", "futures", "itp-node-api/std", + "itp-ocall-api/std", "itp-sgx-crypto/std", "itp-stf-executor/std", "itp-top-pool-author/std", @@ -65,13 +59,12 @@ std = [ "itp-test/std", "itp-types/std", "itp-enclave-metrics/std", + "itp-sgx-runtime-primitives/std", "log/std", - #substrate "binary-merkle-tree/std", - "sp-core/std", "sp-runtime/std", + "sp-core/std", "thiserror", - # litentry "litentry-primitives/std", ] sgx = [ @@ -84,6 +77,5 @@ sgx = [ "itp-enclave-metrics/sgx", "itp-test/sgx", "thiserror_sgx", - # litentry "litentry-primitives/sgx", ] diff --git a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/executor.rs b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/executor.rs index 61ced37b8a..d5b6c0a221 100644 --- a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/executor.rs +++ b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/executor.rs @@ -42,7 +42,10 @@ use itp_stf_primitives::{ }; use itp_top_pool_author::traits::AuthorApi; use itp_types::{ - parentchain::{events::ParentchainBlockProcessed, HandleParentchainEvents, ParentchainId}, + parentchain::{ + events::ParentchainBlockProcessed, HandleParentchainEvents, ParentchainId, + ProcessedEventsArtifacts, + }, MrEnclave, OpaqueCall, RsaRequest, ShardIdentifier, H256, }; use log::*; @@ -141,7 +144,8 @@ impl< NodeMetadataProvider: AccessNodeMetadata, NodeMetadataProvider::MetadataType: NodeMetadataTrait + Clone, EventCreator: EventsFromMetadata, - ParentchainEventHandler: HandleParentchainEvents, + ParentchainEventHandler: + HandleParentchainEvents, TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, G: PartialEq + Encode + Decode + Debug + Clone + Send + Sync, { @@ -274,7 +278,7 @@ impl< PrivacySidechain, TCS, G, - > IndirectExecutor + > IndirectExecutor for IndirectCallsExecutor< ShieldingKeyRepository, StfEnclaveSigner, diff --git a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/filter_metadata.rs b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/filter_metadata.rs index 22abc50bb3..829078a3ce 100644 --- a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/filter_metadata.rs +++ b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/filter_metadata.rs @@ -92,7 +92,8 @@ mod seal { } } - impl, TCS> IndirectDispatch for CantExecute + impl, TCS> IndirectDispatch + for CantExecute where TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, { diff --git a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/mock.rs b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/mock.rs index bc63f95317..c24ebfc863 100644 --- a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/mock.rs +++ b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/mock.rs @@ -2,13 +2,7 @@ use crate::{error::Error, filter_metadata::EventsFromMetadata}; use itp_stf_primitives::traits::IndirectExecutor; use itp_test::mock::stf_mock::TrustedCallSignedMock; use itp_types::{ - parentchain::{ - events::{ - ActivateIdentityRequested, AssertionCreated, DeactivateIdentityRequested, - EnclaveUnauthorized, LinkIdentityRequested, OpaqueTaskPosted, VCRequested, - }, - FilterEvents, HandleParentchainEvents, ProcessedEventsArtifacts, - }, + parentchain::{events::*, FilterEvents, HandleParentchainEvents, ProcessedEventsArtifacts}, RsaRequest, H256, }; use sp_core::H160; @@ -67,18 +61,39 @@ impl FilterEvents for MockEvents { fn get_parentchain_block_proccessed_events( &self, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_btc_wallet_generated_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_enclave_added_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_enclave_removed_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_relayer_added_events(&self) -> Result, Self::Error> { + Ok(Vec::new()) + } + + fn get_relayers_removed_events(&self) -> Result, Self::Error> { Ok(Vec::new()) } } pub struct MockParentchainEventHandler {} -impl HandleParentchainEvents +impl HandleParentchainEvents for MockParentchainEventHandler where - Executor: IndirectExecutor, + Executor: IndirectExecutor, { + type Output = ProcessedEventsArtifacts; fn handle_events( &self, _: &Executor, diff --git a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/traits.rs b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/traits.rs index ada3007406..2f5b70b62f 100644 --- a/tee-worker/identity/core/parentchain/indirect-calls-executor/src/traits.rs +++ b/tee-worker/identity/core/parentchain/indirect-calls-executor/src/traits.rs @@ -58,7 +58,7 @@ pub trait ExecuteIndirectCalls { } /// Trait that should be implemented on indirect calls to be executed. -pub trait IndirectDispatch, TCS> +pub trait IndirectDispatch, TCS> where TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification, { diff --git a/tee-worker/identity/core/parentchain/light-client/Cargo.toml b/tee-worker/identity/core/parentchain/light-client/Cargo.toml deleted file mode 100644 index fa67aee044..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/Cargo.toml +++ /dev/null @@ -1,71 +0,0 @@ -[package] -name = "itc-parentchain-light-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "chain-error"] } -finality-grandpa = { version = "0.16.0", default-features = false, features = ["derive-codec"] } -log = { version = "0.4", default-features = false } -thiserror = { version = "1.0.26", optional = true } - -# sgx-deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["untrusted_fs"], optional = true } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# local deps -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -itp-storage = { path = "../../../core-primitives/storage", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } - -# substrate deps -sp-consensus-grandpa = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# test & mock dependencies -itc-parentchain-test = { optional = true, default-features = false, path = "../../../core/parentchain/test" } -# We can't really make this optional due to feature flag complexities. -itp-sgx-temp-dir = { version = "0.1", default-features = false, path = "../../../core-primitives/sgx/temp-dir" } -itp-test = { optional = true, default-features = false, features = ["sgx"], path = "../../../core-primitives/test" } - -[dev-dependencies] -itc-parentchain-test = { path = "../../../core/parentchain/test" } -itp-test = { path = "../../../core-primitives/test" } -itp-sgx-temp-dir = { version = "0.1", path = "../../../core-primitives/sgx/temp-dir" } - - -[features] -default = ["std"] -std = [ - "codec/std", - "log/std", - "finality-grandpa/std", - "thiserror", - - # substrate deps - "sp-consensus-grandpa/std", - "sp-runtime/std", - - # local deps - "itp-ocall-api/std", - "itp-storage/std", - "itp-sgx-io/std", - "itp-types/std", - # mock deps - "itp-sgx-temp-dir/std", -] -sgx = [ - "sgx_tstd", - "thiserror-sgx", - "itp-sgx-io/sgx", - "itp-storage/sgx", - "itp-sgx-temp-dir/sgx", -] -mocks = [ - "itc-parentchain-test", -] - -test = ["mocks", "itp-test"] diff --git a/tee-worker/identity/core/parentchain/light-client/src/error.rs b/tee-worker/identity/core/parentchain/light-client/src/error.rs deleted file mode 100644 index 8f0276d133..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/error.rs +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{boxed::Box, string::String}; - -use sgx_types::sgx_status_t; -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use thiserror_sgx as thiserror; - -pub type Result = core::result::Result; - -/// Substrate Client error -#[derive(Debug, PartialEq, Eq, thiserror::Error)] -pub enum JustificationError { - #[error("Error decoding justification")] - JustificationDecode, - /// Justification for header is correctly encoded, but invalid. - #[error("bad justification for header: {0}")] - BadJustification(String), - #[error("Invalid authorities set")] - InvalidAuthoritiesSet, -} - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Genesis not found")] - NoGenesis, - #[error(transparent)] - Storage(#[from] itp_storage::Error), - #[error("Validator set mismatch")] - ValidatorSetMismatch, - #[error("Invalid ancestry proof")] - InvalidAncestryProof, - #[error("Invalid Finality Proof: {0}")] - InvalidFinalityProof(#[from] JustificationError), - #[error("Header ancestry mismatch")] - HeaderAncestryMismatch, - #[error("Poisoned validator lock")] - PoisonedLock, - #[error("No Justification found")] - NoJustificationFound, - #[error(transparent)] - Other(#[from] Box), -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Self::Other(e.into()) - } -} - -impl From for Error { - #[cfg(feature = "std")] - fn from(e: codec::Error) -> Self { - Self::Other(e.into()) - } - - #[cfg(not(feature = "std"))] - fn from(e: codec::Error) -> Self { - Self::Other(format!("{:?}", e).into()) - } -} - -impl From for sgx_status_t { - /// return sgx_status for top level enclave functions - fn from(error: Error) -> sgx_status_t { - log::warn!("LightClientError into sgx_status_t: {:?}", error); - sgx_status_t::SGX_ERROR_UNEXPECTED - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/finality.rs b/tee-worker/identity/core/parentchain/light-client/src/finality.rs deleted file mode 100644 index 95371a8863..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/finality.rs +++ /dev/null @@ -1,187 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Finality for determination of the light client validation. - -use crate::{ - error::Result, - grandpa_log, - justification::GrandpaJustification, - state::{RelayState, ScheduledChangeAtBlock}, - AuthorityList, Error, NumberFor, -}; -use finality_grandpa::voter_set::VoterSet; -use log::*; -pub use sp_consensus_grandpa::SetId; -use sp_consensus_grandpa::{AuthorityId, ScheduledChange, GRANDPA_ENGINE_ID}; -use sp_runtime::{ - generic::Digest, - traits::{Block as ParentchainBlockTrait, Header as HeaderTrait}, - EncodedJustification, Justifications, -}; - -#[derive(Default)] -pub struct GrandpaFinality; - -#[derive(Default)] -pub struct ParachainFinality; - -pub trait Finality { - fn validate( - &self, - header: Block::Header, - validator_set: &AuthorityList, - validator_set_id: SetId, - justifications: Option, - relay: &mut RelayState, - ) -> Result<()>; -} - -impl Finality for ParachainFinality -where - Block: ParentchainBlockTrait, -{ - fn validate( - &self, - _header: Block::Header, - _validator_set: &AuthorityList, - _validator_set_id: SetId, - _justifications: Option, - _relay: &mut RelayState, - ) -> Result<()> { - Ok(()) - } -} - -impl Finality for GrandpaFinality -where - Block: ParentchainBlockTrait, - NumberFor: finality_grandpa::BlockNumberOps, -{ - fn validate( - &self, - header: Block::Header, - validator_set: &AuthorityList, - validator_set_id: SetId, - justifications: Option, - relay: &mut RelayState, - ) -> Result<()> { - Self::apply_validator_set_change(relay, &header); - - // Check that the header has been finalized - let voter_set = - VoterSet::new(validator_set.clone().into_iter()).expect("VoterSet may not be empty"); - - // ensure justifications is a grandpa justification - let grandpa_justification = - justifications.and_then(|just| just.into_justification(GRANDPA_ENGINE_ID)); - - let block_hash = header.hash(); - let block_num = *header.number(); - - match grandpa_justification { - Some(justification) => { - if let Err(err) = Self::verify_grandpa_proof::( - justification, - block_hash, - block_num, - validator_set_id, - &voter_set, - ) { - // FIXME: Printing error upon invalid justification, but this will need a better fix - // see issue #353 - error!("Block {:?} contained invalid justification: {:?}", block_num, err); - relay.unjustified_headers.push(block_hash); - relay.set_last_finalized_block_header(header); - return Err(err) - } - Self::schedule_validator_set_change(relay, &header); - - Ok(()) - }, - None => { - relay.unjustified_headers.push(block_hash); - relay.set_last_finalized_block_header(header); - - debug!( - "Syncing finalized block without grandpa proof. Amount of unjustified headers: {}", - relay.unjustified_headers.len() - ); - Err(Error::NoJustificationFound) - }, - } - } -} - -impl GrandpaFinality { - fn apply_validator_set_change( - relay: &mut RelayState, - header: &Block::Header, - ) { - if let Some(change) = relay.scheduled_change.take() { - if &change.at_block == header.number() { - relay.current_validator_set = change.next_authority_list; - relay.current_validator_set_id += 1; - } - } - } - - fn schedule_validator_set_change( - relay: &mut RelayState, - header: &Block::Header, - ) { - if let Some(log) = pending_change::(header.digest()) { - if relay.scheduled_change.is_some() { - error!( - "Tried to scheduled authorities change even though one is already scheduled!!" - ); // should not happen if blockchain is configured properly - } else { - relay.scheduled_change = Some(ScheduledChangeAtBlock { - at_block: log.delay + *header.number(), - next_authority_list: log.next_authorities, - }) - } - } - } - - fn verify_grandpa_proof( - encoded_justification: EncodedJustification, - hash: Block::Hash, - number: NumberFor, - set_id: u64, - voters: &VoterSet, - ) -> Result<()> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - // We don't really care about the justification, as long as it's valid - let _ = GrandpaJustification::::decode_and_verify_finalizes( - &encoded_justification, - (hash, number), - set_id, - voters, - )?; - - Ok(()) - } -} - -fn pending_change( - digest: &Digest, -) -> Option>> { - grandpa_log::(digest).and_then(|log| log.try_into_change()) -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/io.rs b/tee-worker/identity/core/parentchain/light-client/src/io.rs deleted file mode 100644 index 64a7771aaa..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/io.rs +++ /dev/null @@ -1,429 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::{Error, Result}, - finality::{Finality, GrandpaFinality, ParachainFinality}, - light_client_init_params::{GrandpaParams, SimpleParams}, - light_validation::{check_validator_set_proof, LightValidation}, - state::RelayState, - LightClientSealing, LightClientState, LightValidationState, NumberFor, Validator, -}; -use codec::{Decode, Encode}; -use core::{fmt::Debug, marker::PhantomData}; -use itp_ocall_api::EnclaveOnChainOCallApi; -use itp_sgx_io::{seal, unseal}; -use itp_types::parentchain::{IdentifyParentchain, ParentchainId}; -use log::*; -use sp_runtime::traits::{Block, Header}; -use std::{ - boxed::Box, - fs, - path::{Path, PathBuf}, - sync::Arc, -}; - -#[cfg(feature = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -pub const DB_FILE: &str = "db.bin"; -pub const BACKUP_FILE: &str = "db.bin.backup"; - -#[derive(Clone, Debug)] -pub struct LightClientStateSeal { - base_path: PathBuf, - db_path: PathBuf, - backup_path: PathBuf, - parentchain_id: ParentchainId, - _phantom: PhantomData<(B, LightClientState)>, -} - -impl LightClientStateSeal { - pub fn new(base_path: PathBuf, parentchain_id: ParentchainId) -> Result { - std::fs::create_dir_all(&base_path)?; - Ok(Self { - base_path: base_path.clone(), - db_path: base_path.clone().join(DB_FILE), - backup_path: base_path.join(BACKUP_FILE), - parentchain_id, - _phantom: Default::default(), - }) - } - - pub fn base_path(&self) -> &Path { - &self.base_path - } - - pub fn db_path(&self) -> &Path { - &self.db_path - } - - pub fn backup_path(&self) -> &Path { - &self.backup_path - } - - pub fn backup(&self) -> Result<()> { - if self.db_path().exists() { - let _bytes = fs::copy(self.db_path(), self.backup_path())?; - } else { - info!("{} does not exist yet, skipping backup...", self.db_path().display()) - } - Ok(()) - } -} - -impl IdentifyParentchain for LightClientStateSeal { - fn parentchain_id(&self) -> ParentchainId { - self.parentchain_id - } -} - -impl LightClientSealing - for LightClientStateSeal -{ - type LightClientState = LightClientState; - - fn seal(&self, unsealed: &LightClientState) -> Result<()> { - trace!( - "[{:?}] Backup light client state to {}", - self.parentchain_id, - self.backup_path().display() - ); - - if let Err(e) = self.backup() { - warn!( - "[{:?}] Could not backup previous light client state: Error: {}", - self.parentchain_id, e - ); - }; - - trace!( - "[{:?}] Seal light client State. Current state: {:?}", - self.parentchain_id, - unsealed - ); - Ok(unsealed.using_encoded(|bytes| seal(bytes, self.db_path()))?) - } - - // unseals db with automatic failover to db backup - fn unseal(&self) -> Result { - Ok(unseal(self.db_path()) - .or_else(|e| { - warn!( - "can't unseal db at {:?}. error {:?}. trying backup at {:?}", - self.db_path(), - e, - self.backup_path() - ); - // create a copy because we will overwrite the db in the next step - fs::copy(self.db_path(), self.db_path().with_extension("cantunseal")).and_then( - |_| { - fs::copy(self.backup_path(), self.db_path()).and_then(|_| { - unseal(self.db_path()).map_err(|e| { - warn!("{:?}", e); - e - }) - }) - }, - ) - }) - .map(|b| Decode::decode(&mut b.as_slice()))??) - } - - // checks if either the db or its backup can be opened in opaque mode (no unseal) - fn exists(&self) -> bool { - debug!("check if db exists at {:?}", self.db_path()); - fs::File::open(self.db_path()) - .or_else(|e| { - warn!( - "can't open db at {:?}. error: {:?}. trying restore backup at {:?}", - self.db_path(), - e, - self.backup_path() - ); - fs::copy(self.backup_path(), self.db_path()) - .and_then(|_| fs::File::open(self.db_path())) - .map_err(|e| { - warn!("{:?}", e); - e - }) - }) - .is_ok() - } - - fn path(&self) -> &Path { - self.db_path() - } -} - -/// Same as [LightClientStateSeal], but it ensures that no concurrent write operations are done -/// accross different threads. -#[derive(Debug)] -pub struct LightClientStateSealSync { - seal: LightClientStateSeal, - _rw_lock: RwLock<()>, -} - -impl LightClientStateSealSync { - pub fn new(base_path: PathBuf, parentchain_id: ParentchainId) -> Result { - Ok(Self { - seal: LightClientStateSeal::new(base_path, parentchain_id)?, - _rw_lock: RwLock::new(()), - }) - } -} - -impl IdentifyParentchain for LightClientStateSealSync { - fn parentchain_id(&self) -> ParentchainId { - self.seal.parentchain_id - } -} - -impl LightClientSealing - for LightClientStateSealSync -{ - type LightClientState = LightClientState; - - fn seal(&self, unsealed: &LightClientState) -> Result<()> { - let _lock = self._rw_lock.write().map_err(|_| Error::PoisonedLock)?; - self.seal.seal(unsealed) - } - - fn unseal(&self) -> Result { - let _lock = self._rw_lock.read().map_err(|_| Error::PoisonedLock)?; - self.seal.unseal() - } - - fn exists(&self) -> bool { - self.seal.exists() - } - - fn path(&self) -> &Path { - self.seal.path() - } -} - -// FIXME: This is a lot of duplicate code for the initialization of two -// different but sameish light clients. Should be tackled with #1081 -pub fn read_or_init_grandpa_validator( - params: GrandpaParams, - ocall_api: Arc, - seal: &LightClientSeal, - parentchain_id: ParentchainId, -) -> Result> -where - B: Block, - NumberFor: finality_grandpa::BlockNumberOps, - OCallApi: EnclaveOnChainOCallApi, - LightClientSeal: - LightClientSealing> + IdentifyParentchain, -{ - check_validator_set_proof::( - params.genesis_header.state_root(), - params.authority_proof, - ¶ms.authorities, - )?; - - if !seal.exists() { - info!( - "[{:?}] ChainRelay DB for grandpa validator not found, creating new! {}", - seal.parentchain_id(), - seal.path().display() - ); - let validator = init_grandpa_validator::( - ocall_api, - RelayState::new(params.genesis_header, params.authorities).into(), - parentchain_id, - )?; - seal.seal(validator.get_state())?; - return Ok(validator) - } - - let validation_state = seal.unseal()?; - let genesis_hash = validation_state.genesis_hash()?; - - let init_state = if genesis_hash == params.genesis_header.hash() { - info!( - "[{:?}] Found already initialized light client with Genesis Hash: {:?}", - seal.parentchain_id(), - genesis_hash - ); - validation_state - } else { - info!( - "Previous light client db belongs to another parentchain genesis. Creating new: {:?}", - genesis_hash - ); - RelayState::new(params.genesis_header, params.authorities).into() - }; - - let validator = init_grandpa_validator::(ocall_api, init_state, parentchain_id)?; - - info!("[{:?}] light client state: {:?}", seal.parentchain_id(), validator); - - seal.seal(validator.get_state())?; - Ok(validator) -} - -pub fn read_or_init_parachain_validator( - params: SimpleParams, - ocall_api: Arc, - seal: &LightClientSeal, - parentchain_id: ParentchainId, -) -> Result> -where - B: Block, - NumberFor: finality_grandpa::BlockNumberOps, - OCallApi: EnclaveOnChainOCallApi, - LightClientSeal: LightClientSealing>, -{ - trace!("[{:?}] init light client db", parentchain_id); - if !seal.exists() { - info!( - "[{:?}] ChainRelay DB for parachain validator not found, creating new! {}", - parentchain_id, - seal.path().display() - ); - let validator = init_parachain_validator::( - ocall_api, - RelayState::new(params.genesis_header, Default::default()).into(), - parentchain_id, - )?; - seal.seal(validator.get_state())?; - return Ok(validator) - } - - let validation_state = seal.unseal()?; - info!("unseal success"); - let genesis_hash = validation_state.genesis_hash()?; - - let init_state = if genesis_hash == params.genesis_header.hash() { - info!("Found already initialized light client with Genesis Hash: {:?}", genesis_hash); - validation_state - } else { - info!( - "Previous light client db belongs to another parentchain genesis. Creating new: {:?}", - genesis_hash - ); - RelayState::new(params.genesis_header, vec![]).into() - }; - - let validator = init_parachain_validator::(ocall_api, init_state, parentchain_id)?; - info!("light client state: {:?}", validator); - - seal.seal(validator.get_state())?; - Ok(validator) -} - -fn init_grandpa_validator( - ocall_api: Arc, - state: LightValidationState, - parentchain_id: ParentchainId, -) -> Result> -where - B: Block, - NumberFor: finality_grandpa::BlockNumberOps, - OCallApi: EnclaveOnChainOCallApi, -{ - let finality: Arc + Sync + Send + 'static>> = - Arc::new(Box::new(GrandpaFinality)); - - let validator = LightValidation::::new(ocall_api, finality, state, parentchain_id); - - Ok(validator) -} - -fn init_parachain_validator( - ocall_api: Arc, - state: LightValidationState, - parentchain_id: ParentchainId, -) -> Result> -where - B: Block, - NumberFor: finality_grandpa::BlockNumberOps, - OCallApi: EnclaveOnChainOCallApi, -{ - let finality: Arc + Sync + Send + 'static>> = - Arc::new(Box::new(ParachainFinality)); - - let validator = LightValidation::::new(ocall_api, finality, state, parentchain_id); - Ok(validator) -} - -#[cfg(feature = "test")] -pub mod sgx_tests { - use super::{read_or_init_parachain_validator, Arc, LightClientStateSeal, RelayState}; - use crate::{ - light_client_init_params::SimpleParams, LightClientSealing, LightClientState, - LightValidationState, - }; - use itc_parentchain_test::{Block, Header, ParentchainHeaderBuilder}; - use itp_sgx_temp_dir::TempDir; - use itp_test::mock::onchain_mock::OnchainMock; - use itp_types::parentchain::ParentchainId; - use sp_runtime::OpaqueExtrinsic; - - type TestBlock = Block; - type TestSeal = LightClientStateSeal>; - - fn default_simple_params() -> SimpleParams

{ - SimpleParams { genesis_header: ParentchainHeaderBuilder::default().build() } - } - - pub fn init_parachain_light_client_works() { - let parachain_params = default_simple_params(); - let temp_dir = TempDir::with_prefix("init_parachain_light_client_works").unwrap(); - let seal = TestSeal::new(temp_dir.path().to_path_buf(), ParentchainId::Litentry).unwrap(); - - let validator = read_or_init_parachain_validator::( - parachain_params.clone(), - Arc::new(OnchainMock::default()), - &seal, - ParentchainId::Litentry, - ) - .unwrap(); - - assert_eq!(validator.genesis_hash().unwrap(), parachain_params.genesis_header.hash()); - assert_eq!(validator.latest_finalized_header().unwrap(), parachain_params.genesis_header); - assert_eq!( - validator.penultimate_finalized_block_header().unwrap(), - parachain_params.genesis_header - ); - } - - pub fn sealing_creates_backup() { - let params = default_simple_params(); - let temp_dir = TempDir::with_prefix("sealing_creates_backup").unwrap(); - let seal = TestSeal::new(temp_dir.path().to_path_buf(), ParentchainId::Litentry).unwrap(); - let state = RelayState::new(params.genesis_header, Default::default()).into(); - - seal.seal(&state).unwrap(); - let unsealed = seal.unseal().unwrap(); - - assert_eq!(state, unsealed); - - // The first seal operation doesn't create a backup, as there is nothing to backup. - seal.seal(&unsealed).unwrap(); - assert!(seal.backup_path().exists()) - } - - // Todo #1293: add a unit test for the grandpa validator, but this needs a little effort for - // setting up correct finality params. -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/justification.rs b/tee-worker/identity/core/parentchain/light-client/src/justification.rs deleted file mode 100644 index 554f97579f..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/justification.rs +++ /dev/null @@ -1,229 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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, HashSet}, - string::ToString, - vec::Vec, -}; - -use super::error::JustificationError as ClientError; -use codec::{Decode, Encode}; -use finality_grandpa::{voter_set::VoterSet, Error as GrandpaError}; -use log::*; -use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthoritySignature}; -use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; - -/// A commit message for this chain's block type. -pub type Commit = finality_grandpa::Commit< - ::Hash, - NumberFor, - AuthoritySignature, - AuthorityId, ->; - -/// A GRANDPA justification for block finality, it includes a commit message and -/// an ancestry proof including all headers routing all precommit target blocks -/// to the commit target block. Due to the current voting strategy the precommit -/// targets should be the same as the commit target, since honest voters don't -/// vote past authority set change blocks. -/// -/// This is meant to be stored in the db and passed around the network to other -/// nodes, and are used by syncing nodes to prove authority set handoffs. -#[derive(Clone, Encode, Decode, PartialEq, Eq)] -pub struct GrandpaJustification { - round: u64, - pub(crate) commit: Commit, - votes_ancestries: Vec, -} - -impl GrandpaJustification { - /// Decode a GRANDPA justification and validate the commit and the votes' - /// ancestry proofs finalize the given block. - pub fn decode_and_verify_finalizes( - encoded: &[u8], - finalized_target: (Block::Hash, NumberFor), - set_id: u64, - voters: &VoterSet, - ) -> Result, ClientError> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - let justification = GrandpaJustification::::decode(&mut &*encoded) - .map_err(|_| ClientError::JustificationDecode)?; - - let justificated_commit = - (justification.commit.target_hash, justification.commit.target_number); - - if justificated_commit != finalized_target { - Err(ClientError::BadJustification( - "invalid commit target in grandpa justification".to_string(), - )) - } else { - justification.verify_with_voter_set(set_id, voters).map(|_| justification) - } - } - - /// Validate the commit and the votes' ancestry proofs. - pub fn verify(&self, set_id: u64, authorities: AuthorityList) -> Result<(), ClientError> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - let voters = - VoterSet::new(authorities.into_iter()).ok_or(ClientError::InvalidAuthoritiesSet)?; - - self.verify_with_voter_set(set_id, &voters) - } - - fn validate_commit( - &self, - voters: &VoterSet, - ancestry_chain: &AncestryChain, - ) -> Result<(), ClientError> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - match finality_grandpa::validate_commit(&self.commit, voters, ancestry_chain) { - Ok(ref result) if result.is_valid() => Ok(()), - _ => Err(ClientError::BadJustification( - "invalid commit in grandpa justification".to_string(), - )), - } - } - - fn fill_visited_hashes( - &self, - ancestry_chain: &AncestryChain, - precommit_target_hash: Block::Hash, - visited_hashes: &mut HashSet, - ) -> Result<(), ClientError> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - use finality_grandpa::Chain; - if let Ok(route) = ancestry_chain.ancestry(self.commit.target_hash, precommit_target_hash) { - // ancestry starts from parent hash but the precommit target hash has been visited - visited_hashes.insert(precommit_target_hash); - visited_hashes.extend(route.iter()); - Ok(()) - } else { - Err(ClientError::BadJustification( - "invalid precommit ancestry proof in grandpa justification".to_string(), - )) - } - } - - /// Validate the commit and the votes' ancestry proofs. - pub(crate) fn verify_with_voter_set( - &self, - set_id: u64, - voters: &VoterSet, - ) -> Result<(), ClientError> - where - NumberFor: finality_grandpa::BlockNumberOps, - { - let ancestry_chain = AncestryChain::::new(&self.votes_ancestries); - - self.validate_commit(voters, &ancestry_chain)?; - - let mut buf = Vec::new(); - let mut visited_hashes = HashSet::new(); - for signed in self.commit.precommits.iter() { - if !sp_consensus_grandpa::check_message_signature_with_buffer( - &finality_grandpa::Message::Precommit(signed.precommit.clone()), - &signed.id, - &signed.signature, - self.round, - set_id, - &mut buf, - ) { - warn!("Bad signature on message from {:?}", &signed.id); - // return Err(ClientError::BadJustification( - // "invalid signature for precommit in grandpa justification".to_string(), - // )) - } - - if self.commit.target_hash == signed.precommit.target_hash { - continue - } - - self.fill_visited_hashes( - &ancestry_chain, - signed.precommit.target_hash, - &mut visited_hashes, - )?; - } - - let ancestry_hashes = - self.votes_ancestries.iter().map(|h: &Block::Header| h.hash()).collect(); - - if visited_hashes != ancestry_hashes { - return Err(ClientError::BadJustification( - "invalid precommit ancestries in grandpa justification with unused headers" - .to_string(), - )) - } - - Ok(()) - } - - /// The target block number and hash that this justifications proves finality for. - pub fn target(&self) -> (NumberFor, Block::Hash) { - (self.commit.target_number, self.commit.target_hash) - } -} - -/// A utility trait implementing `finality_grandpa::Chain` using a given set of headers. -/// This is useful when validating commits, using the given set of headers to -/// verify a valid ancestry route to the target commit block. -struct AncestryChain { - ancestry: HashMap, -} - -impl AncestryChain { - fn new(ancestry: &[Block::Header]) -> AncestryChain { - let ancestry: HashMap<_, _> = - ancestry.iter().cloned().map(|h: Block::Header| (h.hash(), h)).collect(); - - AncestryChain { ancestry } - } -} - -impl finality_grandpa::Chain> for AncestryChain -where - NumberFor: finality_grandpa::BlockNumberOps, -{ - fn ancestry( - &self, - base: Block::Hash, - block: Block::Hash, - ) -> Result, GrandpaError> { - let mut ancestors = Vec::new(); - let mut current_hash = block; - while current_hash != base { - if let Some(current_header) = self.ancestry.get(¤t_hash) { - current_hash = *current_header.parent_hash(); - ancestors.push(current_hash); - } else { - return Err(GrandpaError::NotDescendent) - } - } - ancestors.pop(); // remove the base - - Ok(ancestors) - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/lib.rs b/tee-worker/identity/core/parentchain/light-client/src/lib.rs deleted file mode 100644 index 64b46c480f..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/lib.rs +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Light-client crate that imports and verifies parentchain blocks. - -#![allow(unused)] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(all(feature = "std", feature = "sgx"))] -compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -#[macro_use] -extern crate sgx_tstd as std; - -// Re-export useful types. -pub use finality_grandpa::BlockNumberOps; -pub use sp_consensus_grandpa::{AuthorityList, SetId}; - -use crate::light_validation_state::LightValidationState; -use error::Error; -use sp_consensus_grandpa::{AuthorityId, AuthorityWeight, ConsensusLog, GRANDPA_ENGINE_ID}; -use sp_runtime::{ - generic::{Digest, OpaqueDigestItemId, SignedBlock}, - traits::{Block as ParentchainBlockTrait, Header as HeaderTrait}, - OpaqueExtrinsic, -}; -use std::{path::Path, vec::Vec}; - -pub mod concurrent_access; -pub mod error; -pub mod finality; -pub mod justification; -pub mod light_client_init_params; -pub mod light_validation; -pub mod light_validation_state; -pub mod state; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod io; - -#[cfg(any(test, feature = "mocks"))] -pub mod mocks; - -pub type RelayId = u64; - -pub type AuthorityListRef<'a> = &'a [(AuthorityId, AuthorityWeight)]; - -// disambiguate associated types -/// Block number type -pub type NumberFor = <::Header as HeaderTrait>::Number; -/// Hash type of Block -pub type HashFor = <::Header as HeaderTrait>::Hash; -/// Hashing function used to produce `HashOf` -pub type HashingFor = <::Header as HeaderTrait>::Hashing; - -/// Validator trait -pub trait Validator -where - NumberFor: finality_grandpa::BlockNumberOps, -{ - fn submit_block(&mut self, signed_block: &SignedBlock) -> Result<(), Error>; - - fn get_state(&self) -> &LightValidationState; - - fn set_ignore_validation_until(&mut self, until: u32) -> Result<(), Error>; -} - -pub trait ExtrinsicSender { - /// Sends encoded extrinsics to the parentchain and cache them internally for later confirmation. - fn send_extrinsics(&mut self, extrinsics: Vec) -> Result<(), Error>; -} - -pub trait LightClientState { - fn genesis_hash(&self) -> Result, Error>; - - fn latest_finalized_header(&self) -> Result; - - // Todo: Check if we still need this after #423 - fn penultimate_finalized_block_header(&self) -> Result; -} - -pub trait LightClientSealing { - type LightClientState; - - fn seal(&self, state: &Self::LightClientState) -> Result<(), Error>; - fn unseal(&self) -> Result; - fn exists(&self) -> bool; - fn path(&self) -> &Path; -} - -pub fn grandpa_log( - digest: &Digest, -) -> Option>> { - let id = OpaqueDigestItemId::Consensus(&GRANDPA_ENGINE_ID); - digest.convert_first(|l| l.try_to::>>(id)) -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/light_client_init_params.rs b/tee-worker/identity/core/parentchain/light-client/src/light_client_init_params.rs deleted file mode 100644 index 114d684382..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/light_client_init_params.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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 codec::{Decode, Encode}; -use sp_consensus_grandpa::AuthorityList; -use std::vec::Vec; - -#[derive(Encode, Decode, Clone)] -pub struct GrandpaParams
{ - pub genesis_header: Header, - pub authorities: AuthorityList, - pub authority_proof: Vec>, -} - -impl
GrandpaParams
{ - pub fn new( - genesis_header: Header, - authorities: AuthorityList, - authority_proof: Vec>, - ) -> Self { - Self { genesis_header, authorities, authority_proof } - } -} - -#[derive(Encode, Decode, Clone)] -pub struct SimpleParams
{ - pub genesis_header: Header, -} - -impl
SimpleParams
{ - pub fn new(genesis_header: Header) -> Self { - Self { genesis_header } - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/light_validation.rs b/tee-worker/identity/core/parentchain/light-client/src/light_validation.rs deleted file mode 100644 index e43bb81984..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/light_validation.rs +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Light-client validation crate that verifies parentchain blocks. - -use crate::{ - error::Error, finality::Finality, light_validation_state::LightValidationState, - state::RelayState, AuthorityList, AuthorityListRef, ExtrinsicSender, HashFor, HashingFor, - LightClientState, NumberFor, RelayId, Validator, -}; -use codec::Encode; -use core::iter::Iterator; -use itp_ocall_api::EnclaveOnChainOCallApi; -use itp_storage::{Error as StorageError, StorageProof, StorageProofChecker}; -use itp_types::parentchain::{IdentifyParentchain, ParentchainId}; -use log::*; -use sp_runtime::{ - generic::SignedBlock, - traits::{Block as ParentchainBlockTrait, Header as HeaderTrait}, - Justifications, OpaqueExtrinsic, -}; -use std::{boxed::Box, fmt, sync::Arc, vec::Vec}; - -#[derive(Clone)] -pub struct LightValidation { - light_validation_state: LightValidationState, - ocall_api: Arc, - parentchain_id: ParentchainId, - finality: Arc + Sync + Send + 'static>>, - ignore_validation_until: NumberFor, -} - -impl IdentifyParentchain - for LightValidation -{ - fn parentchain_id(&self) -> ParentchainId { - self.parentchain_id - } -} - -impl - LightValidation -{ - pub fn new( - ocall_api: Arc, - finality: Arc + Sync + Send + 'static>>, - light_validation_state: LightValidationState, - parentchain_id: ParentchainId, - ) -> Self { - Self { - light_validation_state, - ocall_api, - parentchain_id, - finality, - ignore_validation_until: 0u32.into(), - } - } - - fn check_validator_set_proof( - state_root: &HashFor, - proof: StorageProof, - validator_set: AuthorityListRef, - ) -> Result<(), Error> { - let checker = StorageProofChecker::>::new(*state_root, proof)?; - - // By encoding the given set we should have an easy way to compare - // with the stuff we get out of storage via `read_value` - let mut encoded_validator_set = validator_set.encode(); - encoded_validator_set.insert(0, 1); // Add AUTHORITIES_VERISON == 1 - let actual_validator_set = checker - .read_value(b":grandpa_authorities")? - .ok_or(StorageError::StorageValueUnavailable)?; - - if encoded_validator_set == actual_validator_set { - Ok(()) - } else { - Err(Error::ValidatorSetMismatch) - } - } - - // A naive way to check whether a `child` header is a descendant - // of an `ancestor` header. For this it requires a proof which - // is a chain of headers between (but not including) the `child` - // and `ancestor`. This could be updated to use something like - // Log2 Ancestors (#2053) in the future. - fn verify_ancestry( - proof: Vec, - ancestor_hash: HashFor, - child: &Block::Header, - ) -> Result<(), Error> { - let parent_hash = child.parent_hash(); - if *parent_hash == ancestor_hash { - return Ok(()) - } - - // Find the header's parent hash that matches our ancestor's hash - match proof - .iter() - .find(|header| header.hash() == *parent_hash && *header.parent_hash() == ancestor_hash) - { - Some(_) => Ok(()), - None => Err(Error::InvalidAncestryProof), - } - } - - fn submit_finalized_headers( - &mut self, - header: Block::Header, - ancestry_proof: Vec, - justifications: Option, - ) -> Result<(), Error> { - let relay = self.light_validation_state.get_relay_mut(); - - let validator_set = relay.current_validator_set.clone(); - let validator_set_id = relay.current_validator_set_id; - - if *header.number() > self.ignore_validation_until { - // Check that the new header is a descendant of the old header - let last_header = &relay.last_finalized_block_header; - Self::verify_ancestry(ancestry_proof, last_header.hash(), &header)?; - } - - if let Err(e) = self.finality.validate( - header.clone(), - &validator_set, - validator_set_id, - justifications, - relay, - ) { - match e { - Error::NoJustificationFound => return Ok(()), - _ => return Err(e), - } - } - - // Todo: Justifying the headers here is actually wrong, but it prevents an ever-growing - // `unjustified_headers` queue because in the parachain case we won't have justifications, - // and in solo chain setups we only get a justification upon an Grandpa authority change. - // Hence, we justify the headers here until we properly solve this in #1404. - relay.justify_headers(); - relay.push_header_hash(header.hash()); - - relay.set_last_finalized_block_header(header); - - if validator_set_id > relay.current_validator_set_id { - relay.current_validator_set = validator_set; - relay.current_validator_set_id = validator_set_id; - } - - Ok(()) - } -} - -impl Validator for LightValidation -where - NumberFor: finality_grandpa::BlockNumberOps, - Block: ParentchainBlockTrait, - OCallApi: EnclaveOnChainOCallApi, -{ - fn submit_block(&mut self, signed_block: &SignedBlock) -> Result<(), Error> { - let header = signed_block.block.header(); - let justifications = signed_block.justifications.clone(); - - let relay = self.light_validation_state.get_relay_mut(); - - if *header.number() > self.ignore_validation_until - && relay.last_finalized_block_header.hash() != *header.parent_hash() - { - error!("header ancestry mismatch! last imported was block nr {:?} with hash {:?}, attempting to import nr {:?} with hash {:?} and ancestor {:?}", - relay.last_finalized_block_header.number(), - relay.last_finalized_block_header.hash(), - header.number(), - header.hash(), - header.parent_hash() - ); - return Err(Error::HeaderAncestryMismatch) - } - - self.submit_finalized_headers(header.clone(), vec![], justifications) - } - - fn get_state(&self) -> &LightValidationState { - &self.light_validation_state - } - - fn set_ignore_validation_until(&mut self, until: u32) -> Result<(), Error> { - info!("set ignore parentchain block import validation until: {}", until); - self.ignore_validation_until = until.into(); - Ok(()) - } -} - -impl ExtrinsicSender for LightValidation -where - NumberFor: finality_grandpa::BlockNumberOps, - Block: ParentchainBlockTrait, - OCallApi: EnclaveOnChainOCallApi, -{ - fn send_extrinsics(&mut self, extrinsics: Vec) -> Result<(), Error> { - self.ocall_api - .send_to_parentchain(extrinsics, &self.parentchain_id, false) - .map_err(|e| { - Error::Other( - format!("[{:?}] Failed to send extrinsics: {}", self.parentchain_id, e).into(), - ) - }) - } -} - -impl LightClientState for LightValidation -where - NumberFor: finality_grandpa::BlockNumberOps, - Block: ParentchainBlockTrait, - OCallApi: EnclaveOnChainOCallApi, -{ - fn genesis_hash(&self) -> Result, Error> { - self.light_validation_state.genesis_hash() - } - - fn latest_finalized_header(&self) -> Result { - self.light_validation_state.latest_finalized_header() - } - - fn penultimate_finalized_block_header(&self) -> Result { - self.light_validation_state.penultimate_finalized_block_header() - } -} - -impl fmt::Debug for LightValidation { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "LightValidation {{ parentchain_id: {:?}, relay_state: {:?} }}", - self.parentchain_id, self.light_validation_state.relay_state - ) - } -} - -pub fn check_validator_set_proof( - state_root: &HashFor, - proof: StorageProof, - validator_set: AuthorityListRef, -) -> Result<(), Error> { - let checker = StorageProofChecker::>::new(*state_root, proof)?; - - // By encoding the given set we should have an easy way to compare - // with the stuff we get out of storage via `read_value` - let mut encoded_validator_set = validator_set.encode(); - encoded_validator_set.insert(0, 1); // Add AUTHORITIES_VERISON == 1 - let actual_validator_set = checker - .read_value(b":grandpa_authorities")? - .ok_or(StorageError::StorageValueUnavailable)?; - - if encoded_validator_set == actual_validator_set { - Ok(()) - } else { - Err(Error::ValidatorSetMismatch) - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/light_validation_state.rs b/tee-worker/identity/core/parentchain/light-client/src/light_validation_state.rs deleted file mode 100644 index b86a242677..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/light_validation_state.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! State of the light-client validation. - -use crate::{state::RelayState, Error, HashFor, LightClientState}; -use codec::{Decode, Encode}; -use sp_runtime::traits::Block as ParentchainBlockTrait; - -pub use sp_consensus_grandpa::SetId; - -#[derive(Encode, Decode, Clone, Debug, Eq, PartialEq)] -pub struct LightValidationState { - pub(crate) relay_state: RelayState, -} - -impl From> for LightValidationState { - fn from(value: RelayState) -> Self { - Self::new(value) - } -} - -impl LightValidationState { - pub fn new(relay_state: RelayState) -> Self { - Self { relay_state } - } - - pub(crate) fn get_relay(&self) -> &RelayState { - &self.relay_state - } - - pub(crate) fn get_relay_mut(&mut self) -> &mut RelayState { - &mut self.relay_state - } -} - -impl LightClientState for LightValidationState -where - Block: ParentchainBlockTrait, -{ - fn genesis_hash(&self) -> Result, Error> { - Ok(self.get_relay().genesis_hash) - } - - fn latest_finalized_header(&self) -> Result { - let relay = self.get_relay(); - Ok(relay.last_finalized_block_header.clone()) - } - - fn penultimate_finalized_block_header(&self) -> Result { - let relay = self.get_relay(); - Ok(relay.penultimate_finalized_block_header.clone()) - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/mocks/mod.rs b/tee-worker/identity/core/parentchain/light-client/src/mocks/mod.rs deleted file mode 100644 index 4dedae8c6d..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/mocks/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod validator_access_mock; -pub mod validator_mock; -pub mod validator_mock_seal; diff --git a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_access_mock.rs b/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_access_mock.rs deleted file mode 100644 index c8c775e5a8..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_access_mock.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ - concurrent_access::ValidatorAccess, - error::{Error, Result}, - mocks::validator_mock::ValidatorMock, -}; -use itp_types::{ - parentchain::{IdentifyParentchain, ParentchainId}, - Block, -}; - -/// Mock for the validator access. -/// -/// Does not execute anything, just a stub. -#[derive(Default)] -pub struct ValidatorAccessMock { - validator: RwLock, -} - -impl ValidatorAccess for ValidatorAccessMock { - type ValidatorType = ValidatorMock; - - fn execute_on_validator(&self, getter_function: F) -> Result - where - F: FnOnce(&Self::ValidatorType) -> Result, - { - let validator_lock = self.validator.read().map_err(|_| Error::PoisonedLock)?; - getter_function(&validator_lock) - } - - fn execute_mut_on_validator(&self, mutating_function: F) -> Result - where - F: FnOnce(&mut Self::ValidatorType) -> Result, - { - let mut validator_lock = self.validator.write().map_err(|_| Error::PoisonedLock)?; - mutating_function(&mut validator_lock) - } -} - -impl IdentifyParentchain for ValidatorAccessMock { - fn parentchain_id(&self) -> ParentchainId { - ParentchainId::Litentry - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock.rs b/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock.rs deleted file mode 100644 index ed33d59225..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - error::Result, state::RelayState, ExtrinsicSender, HashFor, LightClientState, - LightValidationState, Validator, -}; -use itc_parentchain_test::ParentchainHeaderBuilder; -use itp_types::Block; -use sp_runtime::{generic::SignedBlock, traits::Block as BlockT, OpaqueExtrinsic}; -use std::vec::Vec; - -type Header = ::Header; - -/// Validator mock to be used in tests. -#[derive(Clone, Debug)] -pub struct ValidatorMock { - light_validation_state: LightValidationState, -} - -impl Default for ValidatorMock { - fn default() -> Self { - Self { - light_validation_state: RelayState::new( - ParentchainHeaderBuilder::default().build(), - Default::default(), - ) - .into(), - } - } -} - -impl Validator for ValidatorMock { - fn submit_block(&mut self, _signed_block: &SignedBlock) -> Result<()> { - Ok(()) - } - - fn get_state(&self) -> &LightValidationState { - &self.light_validation_state - } - - fn set_ignore_validation_until(&mut self, until: u32) -> Result<()> { - Ok(()) - } -} - -impl ExtrinsicSender for ValidatorMock { - fn send_extrinsics(&mut self, _extrinsics: Vec) -> Result<()> { - Ok(()) - } -} - -impl LightClientState for ValidatorMock { - fn genesis_hash(&self) -> Result> { - todo!() - } - - fn latest_finalized_header(&self) -> Result
{ - Ok(ParentchainHeaderBuilder::default().build()) - } - - fn penultimate_finalized_block_header(&self) -> Result
{ - Ok(ParentchainHeaderBuilder::default().build()) - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock_seal.rs b/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock_seal.rs deleted file mode 100644 index 4c7e4f25d3..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/mocks/validator_mock_seal.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{error::Error, state::RelayState, LightClientSealing, LightValidationState}; -use itc_parentchain_test::ParentchainHeaderBuilder; -use itp_sgx_temp_dir::TempDir; -use itp_types::Block; -use std::path::Path; - -/// A seal that returns a mock validator. -#[derive(Clone)] -pub struct LightValidationStateSealMock { - // The directory is deleted when the seal is dropped. - temp_dir: TempDir, -} - -impl LightValidationStateSealMock { - pub fn new() -> Self { - Self { temp_dir: TempDir::new().unwrap() } - } -} - -impl Default for LightValidationStateSealMock { - fn default() -> Self { - Self::new() - } -} - -impl LightClientSealing for LightValidationStateSealMock { - type LightClientState = LightValidationState; - - fn unseal(&self) -> Result, Error> { - Ok(LightValidationState::new(RelayState::new( - ParentchainHeaderBuilder::default().build(), - Default::default(), - ))) - } - - fn seal(&self, _: &LightValidationState) -> Result<(), Error> { - Ok(()) - } - - fn exists(&self) -> bool { - false - } - - fn path(&self) -> &Path { - self.temp_dir.path() - } -} diff --git a/tee-worker/identity/core/parentchain/light-client/src/state.rs b/tee-worker/identity/core/parentchain/light-client/src/state.rs deleted file mode 100644 index e21f86e2e4..0000000000 --- a/tee-worker/identity/core/parentchain/light-client/src/state.rs +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 codec::{Decode, Encode}; -use sp_consensus_grandpa::{AuthorityList, SetId}; -use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; -use std::{collections::VecDeque, fmt, vec::Vec}; - -/// Defines the amount of parentchain headers to keep. -pub const PARENTCHAIN_HEADER_PRUNING: u64 = 1000; - -#[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct RelayState { - pub genesis_hash: Block::Hash, - pub last_finalized_block_header: Block::Header, - pub penultimate_finalized_block_header: Block::Header, - pub current_validator_set: AuthorityList, - pub current_validator_set_id: SetId, - header_hashes: VecDeque, - pub unjustified_headers: Vec, // Finalized headers without grandpa proof - pub scheduled_change: Option>, // Scheduled Authorities change as indicated in the header's digest. -} - -impl RelayState { - pub fn push_header_hash(&mut self, header: Block::Hash) { - self.header_hashes.push_back(header); - - if self.header_hashes.len() > PARENTCHAIN_HEADER_PRUNING as usize { - self.header_hashes.pop_front().expect("Tested above that is not empty; qed"); - } - } - - pub fn justify_headers(&mut self) { - self.header_hashes.extend(&mut self.unjustified_headers.iter()); - self.unjustified_headers.clear(); - - while self.header_hashes.len() > PARENTCHAIN_HEADER_PRUNING as usize { - self.header_hashes.pop_front().expect("Tested above that is not empty; qed"); - } - } - - pub fn header_hashes(&self) -> &VecDeque { - &self.header_hashes - } -} - -#[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct ScheduledChangeAtBlock { - pub at_block: Header::Number, - pub next_authority_list: AuthorityList, -} - -impl RelayState { - pub fn new(genesis: Block::Header, validator_set: AuthorityList) -> Self { - RelayState { - genesis_hash: genesis.hash(), - header_hashes: vec![genesis.hash()].into(), - last_finalized_block_header: genesis.clone(), - // is it bad to initialize with the same? Header trait does no implement default... - penultimate_finalized_block_header: genesis, - current_validator_set: validator_set, - current_validator_set_id: 0, - unjustified_headers: Vec::new(), - scheduled_change: None, - } - } - - pub fn set_last_finalized_block_header(&mut self, header: Block::Header) { - self.penultimate_finalized_block_header = - std::mem::replace(&mut self.last_finalized_block_header, header); - } -} - -impl fmt::Debug for RelayState { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "RelayInfo {{ last_finalized_block_header_number: {:?}, current_validator_set: {:?}, \ - current_validator_set_id: {}, number of unjustified headers: {} }}", - self.last_finalized_block_header.number(), - self.current_validator_set, - self.current_validator_set_id, - self.unjustified_headers.len() - ) - } -} diff --git a/tee-worker/identity/core/parentchain/parentchain-crate/Cargo.toml b/tee-worker/identity/core/parentchain/parentchain-crate/Cargo.toml index 7670ff4920..6a2423e8a6 100644 --- a/tee-worker/identity/core/parentchain/parentchain-crate/Cargo.toml +++ b/tee-worker/identity/core/parentchain/parentchain-crate/Cargo.toml @@ -1,21 +1,19 @@ [package] -name = "itc-parentchain" +name = "id-itc-parentchain" version = "0.1.0" authors = ['Trust Computing GmbH ', 'Integritee AG '] edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "chain-error"] } +codec = { package = "parity-scale-codec", workspace = true, features = ["chain-error"] } -# Parity -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sp-runtime = { workspace = true } -# local -itc-parentchain-block-import-dispatcher = { path = "../block-import-dispatcher", default-features = false } -itc-parentchain-block-importer = { path = "../block-importer", default-features = false } -itc-parentchain-indirect-calls-executor = { path = "../indirect-calls-executor", default-features = false } -itc-parentchain-light-client = { path = "../light-client", default-features = false } -itp-types = { default-features = false, path = "../../../core-primitives/types" } +itc-parentchain-block-import-dispatcher = { package = "id-itc-parentchain-block-import-dispatcher", path = "../block-import-dispatcher", default-features = false } +itc-parentchain-block-importer = { package = "id-itc-parentchain-block-importer", path = "../block-importer", default-features = false } +itc-parentchain-indirect-calls-executor = { package = "id-itc-parentchain-indirect-calls-executor", path = "../indirect-calls-executor", default-features = false } +itc-parentchain-light-client = { workspace = true } +itp-types = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/core/parentchain/parentchain-crate/src/lib.rs b/tee-worker/identity/core/parentchain/parentchain-crate/src/lib.rs index 368ee69967..d9e4e07f55 100644 --- a/tee-worker/identity/core/parentchain/parentchain-crate/src/lib.rs +++ b/tee-worker/identity/core/parentchain/parentchain-crate/src/lib.rs @@ -29,5 +29,3 @@ pub use itc_parentchain_block_importer as block_importer; pub use itc_parentchain_indirect_calls_executor as indirect_calls_executor; pub use itc_parentchain_light_client as light_client; - -pub mod primitives; diff --git a/tee-worker/identity/core/parentchain/parentchain-crate/src/primitives.rs b/tee-worker/identity/core/parentchain/parentchain-crate/src/primitives.rs deleted file mode 100644 index 6a02c99577..0000000000 --- a/tee-worker/identity/core/parentchain/parentchain-crate/src/primitives.rs +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 alloc; - -use crate::light_client::light_client_init_params::{GrandpaParams, SimpleParams}; -use codec::{Decode, Encode}; - -use sp_runtime::traits::Block; - -use itp_types::ShardIdentifier; -pub use itp_types::{parentchain::ParentchainId, Block as ParachainBlock, Block as SolochainBlock}; - -pub type HeaderFor = ::Header; -pub type SolochainHeader = HeaderFor; -pub type ParachainHeader = HeaderFor; -pub type SolochainParams = GrandpaParams; -pub type ParachainParams = SimpleParams; - -/// Initialization primitives, used by both service and enclave. -/// Allows to use a single E-call for the initialization of different parentchain types. -#[derive(Encode, Decode, Clone)] -pub enum ParentchainInitParams { - Solochain { id: ParentchainId, shard: ShardIdentifier, params: SolochainParams }, - Parachain { id: ParentchainId, shard: ShardIdentifier, params: ParachainParams }, -} - -impl ParentchainInitParams { - pub fn id(&self) -> &ParentchainId { - match self { - Self::Solochain { id, .. } => id, - Self::Parachain { id, .. } => id, - } - } - pub fn is_solochain(&self) -> bool { - matches!(self, Self::Solochain { .. }) - } - pub fn is_parachain(&self) -> bool { - matches!(self, Self::Parachain { .. }) - } -} - -impl From<(ParentchainId, ShardIdentifier, SolochainParams)> for ParentchainInitParams { - fn from(value: (ParentchainId, ShardIdentifier, SolochainParams)) -> Self { - Self::Solochain { id: value.0, shard: value.1, params: value.2 } - } -} - -impl From<(ParentchainId, ShardIdentifier, ParachainParams)> for ParentchainInitParams { - fn from(value: (ParentchainId, ShardIdentifier, ParachainParams)) -> Self { - Self::Parachain { id: value.0, shard: value.1, params: value.2 } - } -} diff --git a/tee-worker/identity/core/parentchain/test/Cargo.toml b/tee-worker/identity/core/parentchain/test/Cargo.toml deleted file mode 100644 index e1bc4a6859..0000000000 --- a/tee-worker/identity/core/parentchain/test/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "itc-parentchain-test" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -homepage = 'https://litentry.com/' -repository = 'https://github.com/litentry/litentry-parachain' -license = "Apache-2.0" -edition = "2021" - -[dependencies] -itp-types = { path = "../../../core-primitives/types", default-features = false } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "itp-types/std", - "sp-runtime/std", -] diff --git a/tee-worker/identity/core/parentchain/test/src/lib.rs b/tee-worker/identity/core/parentchain/test/src/lib.rs deleted file mode 100644 index b0ecad2d23..0000000000 --- a/tee-worker/identity/core/parentchain/test/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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. - -*/ - -//! Builder patterns for common structs used in tests. - -#![cfg_attr(not(feature = "std"), no_std)] - -pub mod parentchain_block_builder; -pub mod parentchain_header_builder; - -pub use parentchain_block_builder::{Block, ParentchainBlockBuilder, SignedBlock}; -pub use parentchain_header_builder::{BlockNumber, Header, ParentchainHeaderBuilder, H256}; diff --git a/tee-worker/identity/core/parentchain/test/src/parentchain_block_builder.rs b/tee-worker/identity/core/parentchain/test/src/parentchain_block_builder.rs deleted file mode 100644 index 5b7ea5e081..0000000000 --- a/tee-worker/identity/core/parentchain/test/src/parentchain_block_builder.rs +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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. - -*/ - -//! Builder pattern for a parentchain block. - -extern crate alloc; - -use crate::ParentchainHeaderBuilder; -use alloc::vec::Vec; -use sp_runtime::traits::MaybeSerialize; - -pub use itp_types::Header; -pub use sp_runtime::generic::{Block, SignedBlock}; - -pub struct ParentchainBlockBuilder { - header: Header, - extrinsics: Vec, -} - -impl Default for ParentchainBlockBuilder { - fn default() -> Self { - ParentchainBlockBuilder { - header: ParentchainHeaderBuilder::default().build(), - extrinsics: Default::default(), - } - } -} - -impl ParentchainBlockBuilder { - pub fn with_header(mut self, header: Header) -> Self { - self.header = header; - self - } - - pub fn with_extrinsics(mut self, extrinsics: Vec) -> Self { - self.extrinsics = extrinsics; - self - } - - pub fn build(self) -> Block { - Block { header: self.header, extrinsics: self.extrinsics } - } - - pub fn build_signed(self) -> SignedBlock> { - SignedBlock { block: self.build(), justifications: None } - } -} diff --git a/tee-worker/identity/core/parentchain/test/src/parentchain_header_builder.rs b/tee-worker/identity/core/parentchain/test/src/parentchain_header_builder.rs deleted file mode 100644 index 926f15ce7d..0000000000 --- a/tee-worker/identity/core/parentchain/test/src/parentchain_header_builder.rs +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. - - Licensed 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. - -*/ - -//! Builder pattern for a parentchain header. - -pub use itp_types::{BlockNumber, Header, H256}; -pub use sp_runtime::generic::Digest; - -#[derive(Default)] -pub struct ParentchainHeaderBuilder { - number: BlockNumber, - parent_hash: H256, - state_root: H256, - extrinsic_root: H256, - digest: Digest, -} - -impl ParentchainHeaderBuilder { - pub fn with_number(mut self, number: BlockNumber) -> Self { - self.number = number; - self - } - - pub fn with_parent_hash(mut self, parent_hash: H256) -> Self { - self.parent_hash = parent_hash; - self - } - - pub fn build(self) -> Header { - Header { - number: self.number, - parent_hash: self.parent_hash, - state_root: self.state_root, - extrinsics_root: self.extrinsic_root, - digest: self.digest, - } - } -} diff --git a/tee-worker/identity/core/peer-top-broadcaster/Cargo.toml b/tee-worker/identity/core/peer-top-broadcaster/Cargo.toml index f2c870e4b2..92da70bdb6 100644 --- a/tee-worker/identity/core/peer-top-broadcaster/Cargo.toml +++ b/tee-worker/identity/core/peer-top-broadcaster/Cargo.toml @@ -5,26 +5,20 @@ authors = ['Trust Computing GmbH '] edition = "2021" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +sgx_tstd = { workspace = true, optional = true } -# no-std dependencies -log = { version = "0.4", default-features = false } +log = { workspace = true } -# local dependencies -itc-direct-rpc-client = { path = "../direct-rpc-client", default-features = false } -itc-direct-rpc-server = { path = "../direct-rpc-server", default-features = false } -itp-rpc = { path = "../../core-primitives/rpc", default-features = false } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-types = { path = "../../core-primitives/types", default-features = false } -itp-utils = { path = "../../core-primitives/utils", default-features = false } - -# litentry -litentry-primitives = { path = "../../litentry/primitives", default-features = false } +itc-direct-rpc-client = { package = "id-itc-direct-rpc-client", path = "../direct-rpc-client", default-features = false } +itc-direct-rpc-server = { package = "id-itc-direct-rpc-server", path = "../direct-rpc-server", default-features = false } +itp-rpc = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -itc-direct-rpc-server = { path = "../direct-rpc-server", default-features = false, features = ["mocks"] } - +itc-direct-rpc-server = { package = "id-itc-direct-rpc-server", path = "../direct-rpc-server", default-features = false, features = ["mocks"] } [features] default = ["std"] diff --git a/tee-worker/identity/core/peer-top-broadcaster/src/lib.rs b/tee-worker/identity/core/peer-top-broadcaster/src/lib.rs index 1d8f5310e7..9e2a084caf 100644 --- a/tee-worker/identity/core/peer-top-broadcaster/src/lib.rs +++ b/tee-worker/identity/core/peer-top-broadcaster/src/lib.rs @@ -138,7 +138,9 @@ where } }, - DirectRequestStatus::Ok | DirectRequestStatus::Error => { + DirectRequestStatus::Ok + | DirectRequestStatus::Error + | DirectRequestStatus::Processing(_) => { log::warn!( "Got unexpected direct request status: {:?}", rpc_return_value.status diff --git a/tee-worker/identity/core/rest-client/Cargo.toml b/tee-worker/identity/core/rest-client/Cargo.toml deleted file mode 100644 index 7474626716..0000000000 --- a/tee-worker/identity/core/rest-client/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "itc-rest-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# std dependencies -http = { version = "0.2", optional = true } -http_req = { optional = true, features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } -thiserror = { version = "1.0.26", optional = true } - -# sgx dependencies -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -http_req-sgx = { optional = true, default-features = false, features = ["rust-tls", "sgx"], package = "http_req", git = "https://github.com/integritee-network/http_req" } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# no_std dependencies -base64 = { version = "0.13", default-features = false, features = ["alloc"] } -log = { version = "0.4", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } - -[features] -default = ["std"] -std = [ - # std only - "http", - "http_req", - "thiserror", - # no_std - "base64/std", - "serde/std", - "serde_json/std", - "log/std", - "url/std", -] -sgx = [ - "http-sgx", - "http_req-sgx", - "sgx_tstd", - "thiserror_sgx", -] diff --git a/tee-worker/identity/core/rest-client/src/error.rs b/tee-worker/identity/core/rest-client/src/error.rs deleted file mode 100644 index 8dea50ccfc..0000000000 --- a/tee-worker/identity/core/rest-client/src/error.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use std::string::String; - -/// REST client error -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("HTTP client creation failed")] - HttpClientError, - - #[error("Failed to parse final URL.")] - UrlError, - - #[error("Failed to serialize struct to JSON (in POST): {0}")] - SerializeParseError(serde_json::Error), - - #[error("Failed to deserialize data to struct (in GET or POST response: {0} {1}")] - DeserializeParseError(serde_json::Error, String), - - #[error("Failed to make the outgoing request")] - RequestError, - - #[error("HTTP header error: {0}")] - HttpHeaderError(http::header::ToStrError), - - #[error(transparent)] - HttpReqError(#[from] http_req::error::Error), - - #[error("Failed to perform IO operation: {0}")] - IoError(std::io::Error), - - #[error("Server returned non-success status: {0}, details: {1}")] - HttpError(u16, String), - - #[error("Request has timed out")] - TimeoutError, - - #[error("Invalid parameter value")] - InvalidValue, -} diff --git a/tee-worker/identity/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem b/tee-worker/identity/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem deleted file mode 100644 index a6f3e92af5..0000000000 --- a/tee-worker/identity/core/rest-client/src/fixtures/amazon_root_ca_1_v3.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF -ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 -b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL -MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv -b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj -ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM -9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw -IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6 -VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L -93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm -jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC -AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA -A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI -U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs -N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv -o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU -5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy -rqXRfboQnoZsG4q5WTP468SQvvG5 ------END CERTIFICATE----- diff --git a/tee-worker/identity/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem b/tee-worker/identity/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem deleted file mode 100644 index 519028c63b..0000000000 --- a/tee-worker/identity/core/rest-client/src/fixtures/baltimore_cyber_trust_root_v3.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ -RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD -VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX -DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y -ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy -VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr -mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr -IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK -mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu -XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy -dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye -jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1 -BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3 -DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92 -9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx -jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0 -Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz -ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS -R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp ------END CERTIFICATE----- diff --git a/tee-worker/identity/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem b/tee-worker/identity/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem deleted file mode 100644 index 57d4a3766c..0000000000 --- a/tee-worker/identity/core/rest-client/src/fixtures/lets_encrypt_root_cert.pem +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw -TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh -cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4 -WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu -ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY -MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc -h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+ -0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U -A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW -T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH -B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC -B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv -KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn -OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn -jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw -qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI -rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV -HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq -hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL -ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ -3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK -NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5 -ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur -TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC -jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc -oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq -4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA -mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d -emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc= ------END CERTIFICATE----- \ No newline at end of file diff --git a/tee-worker/identity/core/rest-client/src/mocks/mod.rs b/tee-worker/identity/core/rest-client/src/mocks/mod.rs deleted file mode 100644 index 404a1b35d3..0000000000 --- a/tee-worker/identity/core/rest-client/src/mocks/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod http_client_mock; diff --git a/tee-worker/identity/core/rpc-client/Cargo.toml b/tee-worker/identity/core/rpc-client/Cargo.toml deleted file mode 100644 index dbaaf3bb57..0000000000 --- a/tee-worker/identity/core/rpc-client/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "itc-rpc-client" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -# crates.io -base58 = "0.2" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } -log = "0.4" -openssl = { version = "0.10" } -parking_lot = "0.12.1" -serde_json = "1.0" -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -thiserror = { version = "1.0" } -url = { version = "2.0.0" } -ws = { version = "0.9.1", features = ["ssl"] } - -# parity -frame-metadata = { version = "15.1.0", features = ["v14"] } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } - -# local -itp-api-client-types = { path = "../../core-primitives/node-api/api-client-types" } -itp-rpc = { path = "../../core-primitives/rpc" } -itp-types = { path = "../../core-primitives/types" } -itp-utils = { path = "../../core-primitives/utils" } - -# litentry -ita-stf = { path = "../../app-libs/stf" } -itp-stf-primitives = { path = "../../core-primitives/stf-primitives" } -litentry-primitives = { path = "../../litentry/primitives", default-features = false } - -[dev-dependencies] -env_logger = "0.9.0" -itc-tls-websocket-server = { path = "../tls-websocket-server", features = ["mocks"] } -itp-networking-utils = { path = "../../core-primitives/networking-utils" } -rustls = { version = "0.19", features = ["dangerous_configuration"] } diff --git a/tee-worker/identity/core/rpc-client/src/direct_client.rs b/tee-worker/identity/core/rpc-client/src/direct_client.rs deleted file mode 100644 index fb15310428..0000000000 --- a/tee-worker/identity/core/rpc-client/src/direct_client.rs +++ /dev/null @@ -1,389 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -//! Interface for direct access to a workers rpc. - -pub use crate::error::{Error, Result}; -use crate::ws_client::{WsClient, WsClientControl}; -use base58::ToBase58; -use codec::{Decode, Encode}; -use frame_metadata::RuntimeMetadataPrefixed; -use ita_stf::{Getter, PublicGetter}; -use itp_api_client_types::Metadata; -use itp_rpc::{Id, RpcRequest, RpcResponse, RpcReturnValue}; -use itp_stf_primitives::types::ShardIdentifier; -use itp_types::{DirectRequestStatus, MrEnclave, RsaRequest}; -use itp_utils::{FromHexPrefixed, ToHexPrefixed}; -use litentry_primitives::Identity; -use log::*; -use sgx_crypto_helper::rsa3072::Rsa3072PubKey; -use sp_core::H256; -use std::{ - sync::{ - mpsc::{channel, Sender as MpscSender}, - Arc, - }, - thread, - thread::JoinHandle, -}; - -#[derive(Clone)] -pub struct DirectClient { - url: String, - web_socket_control: Arc, -} -pub trait DirectApi { - /// Server connection with only one response. - fn get(&self, request: &str) -> Result; - /// Server connection with more than one response. - fn watch(&self, request: String, sender: MpscSender) -> JoinHandle<()>; - fn get_rsa_pubkey(&self) -> Result; - fn get_mu_ra_url(&self) -> Result; - fn get_untrusted_worker_url(&self) -> Result; - fn get_state_metadata(&self) -> Result; - fn send(&self, request: &str) -> Result<()>; - fn import_sidechain_blocks(&self, blocks_encoded: String) -> Result<()>; - - /// Close any open websocket connection. - fn close(&self) -> Result<()>; - - // litentry - fn get_state_metadata_raw(&self) -> Result; - fn get_next_nonce(&self, shard: &ShardIdentifier, account: &Identity) -> Result; - fn get_state_mrenclave(&self) -> Result; - fn get_id_graph_hash(&self, shard: &ShardIdentifier, identity: &Identity) -> Result; -} - -impl DirectClient { - pub fn new(url: String) -> Self { - Self { url, web_socket_control: Default::default() } - } - - // litentry: moved from `cli/src/trusted_operation.rs` as it's more widely used - pub fn get_state(&self, shard: ShardIdentifier, getter: &Getter) -> Option> { - // Compose jsonrpc call. - let data = RsaRequest::new(shard, getter.encode()); - let rpc_method = "state_executeGetter".to_owned(); - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - rpc_method, - vec![data.to_hex()], - ) - .unwrap(); - - let rpc_response_str = self.get(&jsonrpc_call).unwrap(); - - // Decode RPC response. - let rpc_response: RpcResponse = serde_json::from_str(&rpc_response_str).ok()?; - let rpc_return_value = RpcReturnValue::from_hex(&rpc_response.result) - // Replace with `inspect_err` once it's stable. - .map_err(|e| { - error!("Failed to decode RpcReturnValue: {:?}", e); - e - }) - .ok()?; - - if rpc_return_value.status == DirectRequestStatus::Error { - println!("[Error] {}", String::decode(&mut rpc_return_value.value.as_slice()).unwrap()); - return None - } - - let maybe_state = Option::decode(&mut rpc_return_value.value.as_slice()) - // Replace with `inspect_err` once it's stable. - .map_err(|e| { - error!("Failed to decode return value: {:?}", e); - e - }) - .ok()?; - - maybe_state - } - - // common helper function for `get_state_metadata` and `get_state_metadata_raw` - fn get_metadata_internal(&self) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "state_getMetadata".to_string(), - Default::default(), - )?; - - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - - // Decode rpc response. - let rpc_response: RpcResponse = serde_json::from_str(&response_str)?; - let rpc_return_value = RpcReturnValue::from_hex(&rpc_response.result) - .map_err(|e| Error::Custom(format!("{:?}", e).into()))?; - - // Decode Metadata. - RuntimeMetadataPrefixed::decode(&mut rpc_return_value.value.as_slice()) - .map_err(|e| e.into()) - } -} - -impl Drop for DirectClient { - fn drop(&mut self) { - if let Err(e) = self.close() { - error!("Failed to close web-socket connection: {:?}", e); - } - } -} - -impl DirectApi for DirectClient { - fn get(&self, request: &str) -> Result { - let (port_in, port_out) = channel(); - - debug!("[WorkerApi Direct]: (get) Sending request: {:?}", request); - WsClient::connect_one_shot(&self.url, request, port_in)?; - trace!("Waiting for web-socket result.."); - port_out.recv().map_err(Error::MspcReceiver) - } - - fn watch(&self, request: String, sender: MpscSender) -> JoinHandle<()> { - debug!("[WorkerApi Direct]: (watch) Sending request: {:?}", request); - let url = self.url.clone(); - - let web_socket_control = self.web_socket_control.clone(); - // Unwrap is fine here, because JoinHandle can be used to handle a Thread panic. - thread::spawn(move || { - WsClient::connect_watch_with_control(&url, &request, &sender, web_socket_control) - .expect("Connection failed") - }) - } - - fn get_rsa_pubkey(&self) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "author_getShieldingKey".to_string(), - Default::default(), - )?; - - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - - let shielding_pubkey_string = decode_from_rpc_response::(&response_str)?; - let shielding_pubkey: Rsa3072PubKey = serde_json::from_str(&shielding_pubkey_string)?; - - info!("[+] Got RSA public key of enclave"); - Ok(shielding_pubkey) - } - - fn get_mu_ra_url(&self) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "author_getMuRaUrl".to_string(), - Default::default(), - )?; - - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - - let mu_ra_url: String = decode_from_rpc_response::(&response_str)?; - - info!("[+] Got mutual remote attestation url of enclave: {}", mu_ra_url); - Ok(mu_ra_url) - } - - fn get_untrusted_worker_url(&self) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "author_getUntrustedUrl".to_string(), - Default::default(), - )?; - - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - - let untrusted_url: String = decode_from_rpc_response::(&response_str)?; - - trace!("Got untrusted websocket url of worker: {}", untrusted_url); - Ok(untrusted_url) - } - - fn get_state_metadata(&self) -> Result { - let metadata = self.get_metadata_internal()?; - Metadata::try_from(metadata).map_err(|e| e.into()) - } - - fn send(&self, request: &str) -> Result<()> { - self.web_socket_control.send(request) - } - - fn import_sidechain_blocks(&self, blocks_encoded: String) -> Result<()> { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "sidechain_importBlock".to_owned(), - vec![blocks_encoded], - )?; - self.get(&jsonrpc_call)?; - Ok(()) - } - - fn close(&self) -> Result<()> { - self.web_socket_control.close_connection() - } - - fn get_state_metadata_raw(&self) -> Result { - let metadata = self.get_metadata_internal()?.to_hex(); - let rpc_response = - RpcResponse { jsonrpc: "2.0".to_owned(), result: metadata, id: Id::Number(1) }; - serde_json::to_string(&rpc_response).map_err(|e| Error::Custom(Box::new(e))) - } - - fn get_next_nonce(&self, shard: &ShardIdentifier, account: &Identity) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "author_getNextNonce".to_owned(), - vec![shard.encode().to_base58(), account.to_hex()], - ) - .unwrap(); - debug!("[+] get_next_nonce jsonrpc_call: {}", jsonrpc_call); - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - debug!("[+] get_next_nonce response_str: {}", response_str); - decode_from_rpc_response::(&response_str) - } - - fn get_state_mrenclave(&self) -> Result { - let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call( - Id::Text("1".to_string()), - "state_getMrenclave".to_string(), - Default::default(), - )?; - - // Send json rpc call to ws server. - let response_str = self.get(&jsonrpc_call)?; - - let mrenclave: MrEnclave = decode_from_rpc_response::(&response_str)?; - - info!("[+] Got enclave: {:?}", mrenclave); - Ok(mrenclave) - } - - fn get_id_graph_hash(&self, shard: &ShardIdentifier, identity: &Identity) -> Result { - let getter = Getter::public(PublicGetter::id_graph_hash(identity.clone())); - self.get_state(*shard, &getter) - .ok_or_else(|| Error::Status("failed to get state".to_string())) - .and_then(|v| H256::decode(&mut v.as_slice()).map_err(Error::Codec)) - } -} - -fn decode_from_rpc_response(json_rpc_response: &str) -> Result { - let rpc_response: RpcResponse = serde_json::from_str(json_rpc_response)?; - let rpc_return_value = RpcReturnValue::from_hex(&rpc_response.result) - .map_err(|e| Error::Custom(format!("{:?}", e).into()))?; - - let response_message = T::decode(&mut rpc_return_value.value.as_slice())?; - match rpc_return_value.status { - DirectRequestStatus::Ok => Ok(response_message), - _ => Err(Error::Status(format!("decode_response failed to decode {:?}", response_message))), - } -} - -#[cfg(test)] -mod tests { - use super::*; - use itc_tls_websocket_server::{test::fixtures::test_server::create_server, WebSocketServer}; - use itp_networking_utils::ports::get_available_port_in_range; - use std::vec; - - #[test] - fn watch_works_and_closes_connection_on_demand() { - let _ = env_logger::builder().is_test(true).try_init(); - - const END_MESSAGE: &str = "End of service."; - let responses = vec![END_MESSAGE.to_string()]; - - let port = get_available_port_in_range(21000..21500).unwrap(); - let (server, handler) = create_server(responses, port); - - let server_clone = server.clone(); - let server_join_handle = thread::spawn(move || { - if let Err(e) = server_clone.run() { - error!("Web-socket server failed: {:?}", e); - } - }); - - // Wait until server is up. - while !server.is_running().unwrap() { - thread::sleep(std::time::Duration::from_millis(50)); - } - - let client = DirectClient::new(format!("wss://localhost:{}", port)); - let (message_sender, message_receiver) = channel::(); - - let client_join_handle = client.watch("Request".to_string(), message_sender); - - let mut messages = Vec::::new(); - loop { - info!("Client waiting to receive answer.. "); - let message = message_receiver.recv().unwrap(); - info!("Received answer: {}", message); - let do_close = message.as_str() == END_MESSAGE; - messages.push(message); - - if do_close { - info!("Client closing connection"); - break - } - } - - info!("Joining client thread"); - client.close().unwrap(); - client_join_handle.join().unwrap(); - - info!("Joining server thread"); - server.shut_down().unwrap(); - server_join_handle.join().unwrap(); - - assert_eq!(1, messages.len()); - assert_eq!(1, handler.messages_handled.read().unwrap().len()); - } - - #[test] - fn get_works_and_closes_connection() { - let _ = env_logger::builder().is_test(true).try_init(); - - let server_response = "response 1".to_string(); - let responses = vec![server_response.clone()]; - - let port = get_available_port_in_range(21501..22000).unwrap(); - let (server, handler) = create_server(responses, port); - - let server_clone = server.clone(); - let server_join_handle = thread::spawn(move || { - if let Err(e) = server_clone.run() { - error!("Web-socket server failed: {:?}", e); - } - }); - - // Wait until server is up. - while !server.is_running().unwrap() { - thread::sleep(std::time::Duration::from_millis(50)); - } - - let client = DirectClient::new(format!("wss://localhost:{}", port)); - let received_response = client.get("Request").unwrap(); - - info!("Joining server thread"); - server.shut_down().unwrap(); - server_join_handle.join().unwrap(); - - assert_eq!(server_response, received_response); - assert_eq!(1, handler.messages_handled.read().unwrap().len()); - } -} diff --git a/tee-worker/identity/core/rpc-client/src/error.rs b/tee-worker/identity/core/rpc-client/src/error.rs deleted file mode 100644 index f5ef6541c8..0000000000 --- a/tee-worker/identity/core/rpc-client/src/error.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 codec::Error as CodecError; -use itp_api_client_types::InvalidMetadataError; -use serde_json::Error as JsonError; -use std::{boxed::Box, sync::mpsc::RecvError}; -use thiserror; -use ws::Error as WsClientError; - -pub type Result = core::result::Result; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("{0}")] - Codec(#[from] CodecError), - #[error("{0}")] - SerdeJson(#[from] JsonError), - #[error("Validateer returned the following error message: {0}")] - Status(String), - #[error("Websocket error: {0}")] - WsClientError(#[from] WsClientError), - #[error("Faulty channel: {0}")] - MspcReceiver(#[from] RecvError), - #[error("InvalidMetadata: {0:?}")] - InvalidMetadata(InvalidMetadataError), - #[error("Custom Error: {0}")] - Custom(Box), -} - -impl From for Error { - fn from(error: InvalidMetadataError) -> Self { - Error::InvalidMetadata(error) - } -} diff --git a/tee-worker/identity/core/rpc-client/src/lib.rs b/tee-worker/identity/core/rpc-client/src/lib.rs deleted file mode 100644 index 59c9949911..0000000000 --- a/tee-worker/identity/core/rpc-client/src/lib.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod direct_client; -pub mod error; -#[cfg(test)] -pub mod mock; -pub mod ws_client; diff --git a/tee-worker/identity/core/rpc-client/src/ws_client.rs b/tee-worker/identity/core/rpc-client/src/ws_client.rs deleted file mode 100644 index 690adc1686..0000000000 --- a/tee-worker/identity/core/rpc-client/src/ws_client.rs +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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. - -*/ - -///! Websocket client implementation to access the direct-rpc-server running inside an enclave. -/// -/// This should be replaced with the `jsonrpsee::WsClient`as soon as available in no-std: -/// https://github.com/paritytech/jsonrpsee/issues/1 -use crate::error::{Error, Result as RpcClientResult}; -use log::*; -use openssl::ssl::{SslConnector, SslMethod, SslStream, SslVerifyMode}; -use parking_lot::Mutex; -use std::sync::{mpsc::Sender as MpscSender, Arc}; -use url::{self}; -use ws::{connect, util::TcpStream, CloseCode, Handler, Handshake, Message, Result, Sender}; - -/// Control a registered web-socket client. -#[derive(Default)] -pub struct WsClientControl { - subscriber: Mutex>, -} - -impl Clone for WsClientControl { - fn clone(&self) -> Self { - WsClientControl { subscriber: Mutex::new(self.subscriber.lock().clone()) } - } -} - -impl WsClientControl { - pub fn close_connection(&self) -> RpcClientResult<()> { - if let Some(s) = self.subscriber.lock().as_ref() { - debug!("Closing connection"); - s.close(CloseCode::Normal)?; - debug!("Connection is closed"); - } - Ok(()) - } - - fn subscribe_sender(&self, sender: Sender) -> RpcClientResult<()> { - let mut subscriber_lock = self.subscriber.lock(); - *subscriber_lock = Some(sender); - Ok(()) - } - - pub fn send(&self, request: &str) -> RpcClientResult<()> { - if let Some(s) = self.subscriber.lock().as_ref() { - s.send(request)?; - Ok(()) - } else { - Err(Error::Custom("Sender not initialized".into())) - } - } -} - -#[derive(Clone)] -pub struct WsClient { - web_socket: Sender, - request: String, - result: MpscSender, - do_watch: bool, -} - -impl WsClient { - /// Connect a web-socket client for multiple request/responses. - /// - /// Control over the connection is done using the provided client control. - /// (e.g. shutdown has to be initiated explicitly). - #[allow(clippy::result_large_err)] - pub fn connect_watch_with_control( - url: &str, - request: &str, - result: &MpscSender, - control: Arc, - ) -> Result<()> { - debug!("Connecting web-socket connection with watch"); - connect(url.to_string(), |out| { - control.subscribe_sender(out.clone()).expect("Failed sender subscription"); - WsClient::new(out, request.to_string(), result.clone(), true) - }) - } - - /// Connects a web-socket client for a one-shot request. - #[allow(clippy::result_large_err)] - pub fn connect_one_shot(url: &str, request: &str, result: MpscSender) -> Result<()> { - debug!("Connecting one-shot web-socket connection"); - connect(url.to_string(), |out| { - debug!("Create new web-socket client"); - WsClient::new(out, request.to_string(), result.clone(), false) - }) - } - - fn new( - web_socket: Sender, - request: String, - result: MpscSender, - do_watch: bool, - ) -> WsClient { - WsClient { web_socket, request, result, do_watch } - } -} - -impl Handler for WsClient { - fn on_open(&mut self, _: Handshake) -> Result<()> { - debug!("sending request: {:?}", self.request.clone()); - match self.web_socket.send(self.request.clone()) { - Ok(_) => Ok(()), - Err(e) => Err(e), - } - } - - fn on_message(&mut self, msg: Message) -> Result<()> { - trace!("got message"); - trace!("{}", msg); - trace!("sending result to MpscSender.."); - self.result.send(msg.to_string()).expect("Failed to send"); - if !self.do_watch { - debug!("do_watch is false, closing connection"); - self.web_socket.close(CloseCode::Normal).expect("Failed to close connection"); - debug!("Connection close requested"); - } - debug!("on_message successful, returning"); - Ok(()) - } - - fn on_close(&mut self, _code: CloseCode, _reason: &str) { - debug!("Web-socket close"); - self.web_socket.shutdown().expect("Failed to shutdown") - } - - /// we are overriding the `upgrade_ssl_client` method in order to disable hostname verification - /// this is taken from https://github.com/housleyjk/ws-rs/blob/master/examples/unsafe-ssl-client.rs - /// TODO: hostname verification should probably be enabled again for production? - fn upgrade_ssl_client( - &mut self, - sock: TcpStream, - _: &url::Url, - ) -> Result> { - let mut builder = SslConnector::builder(SslMethod::tls_client()).map_err(|e| { - ws::Error::new( - ws::ErrorKind::Internal, - format!("Failed to upgrade client to SSL: {}", e), - ) - })?; - builder.set_verify(SslVerifyMode::empty()); - - let connector = builder.build(); - connector - .configure() - .expect("Invalid connection config") - .use_server_name_indication(false) - .verify_hostname(false) - .connect("", sock) - .map_err(From::from) - } -} diff --git a/tee-worker/identity/core/rpc-server/Cargo.toml b/tee-worker/identity/core/rpc-server/Cargo.toml index fa66ad848f..273773b34d 100644 --- a/tee-worker/identity/core/rpc-server/Cargo.toml +++ b/tee-worker/identity/core/rpc-server/Cargo.toml @@ -9,17 +9,16 @@ anyhow = "1.0.40" jsonrpsee = { version = "0.2.0-alpha.7", features = ["full"] } tokio = { version = "1.6.1", features = ["full"] } -# local -its-peer-fetch = { path = "../../sidechain/peer-fetch" } -its-primitives = { path = "../../sidechain/primitives" } -its-storage = { path = "../../sidechain/storage" } +its-peer-fetch = { workspace = true, features = ["std"] } +its-primitives = { workspace = true, features = ["std"] } +its-storage = { workspace = true } + +[dev-dependencies] +env_logger = { workspace = true } +sp-core = { workspace = true, features = ["std"] } +its-test = { path = "../../sidechain/test" } +codec = { workspace = true, features = ["std"] } [features] default = ["std"] std = [] - -[dev-dependencies] -env_logger = { version = "*" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -its-test = { path = "../../sidechain/test" } -codec = { package = "parity-scale-codec", version = "3.0.0" } diff --git a/tee-worker/identity/core/tls-websocket-server/Cargo.toml b/tee-worker/identity/core/tls-websocket-server/Cargo.toml deleted file mode 100644 index 3d50a3d177..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/Cargo.toml +++ /dev/null @@ -1,70 +0,0 @@ -[package] -name = "itc-tls-websocket-server" -version = "0.1.0" -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = "2021" - -[dependencies] -bit-vec = { version = "0.6", default-features = false } -chrono = { version = "0.4.19", default-features = false, features = ["alloc"] } -rcgen = { package = "rcgen", default-features = false, git = "https://github.com/integritee-network/rcgen" } - -# sgx dependencies -sgx_tstd = { optional = true, features = ["net", "thread"], git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master" } - -# sgx enabled external libraries -mio-extras = { optional = true, default-features = false, git = "https://github.com/integritee-network/mio-extras-sgx", rev = "963234b" } -mio_sgx = { package = "mio", optional = true, git = "https://github.com/mesalock-linux/mio-sgx", tag = "sgx_1.1.3" } -rustls_sgx = { package = "rustls", optional = true, git = "https://github.com/mesalock-linux/rustls", branch = "mesalock_sgx" } -thiserror_sgx = { package = "thiserror", optional = true, git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3" } -tungstenite_sgx = { package = "tungstenite", optional = true, features = ["rustls-tls-webpki-roots"], git = "https://github.com/integritee-network/tungstenite-rs-sgx", branch = "sgx-experimental" } -webpki_sgx = { package = "webpki", optional = true, git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } -yasna_sgx = { package = "yasna", optional = true, default-features = false, features = ["bit-vec", "num-bigint", "chrono", "mesalock_sgx"], git = "https://github.com/mesalock-linux/yasna.rs-sgx", rev = "sgx_1.1.3" } - -# std compatible external libraries (make sure these versions match with the sgx-enabled ones above) -mio = { version = "0.6.14", optional = true } -rustls = { version = "0.19", optional = true } -thiserror = { version = "1.0", optional = true } -tungstenite = { version = "0.15.0", optional = true, features = ["rustls-tls-webpki-roots"] } -webpki = { version = "0.21", optional = true } -yasna = { version = "0.4", optional = true, features = ["bit-vec", "num-bigint", "chrono", "std"] } - -# Substrate dependencies -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -# no-std compatible libraries -log = { version = "0.4", default-features = false } - -[dev-dependencies] -env_logger = "0.9.0" -rustls = { version = "0.19", features = ["dangerous_configuration"] } -url = { version = "2.0.0" } - - -[features] -default = ["std"] -sgx = [ - "mio-extras/sgx", - "mio_sgx", - "rcgen/sgx", - "rcgen/pem_sgx", - "rustls_sgx", - "sgx_tstd", - "thiserror_sgx", - "tungstenite_sgx", - "webpki_sgx", - "yasna_sgx", -] -std = [ - "mio", - "mio-extras/std", - "rcgen/std", - "rcgen/pem", - "rustls", - "thiserror", - "tungstenite", - "webpki", - "yasna", - "log/std", -] -mocks = [] diff --git a/tee-worker/identity/core/tls-websocket-server/src/certificate_generation.rs b/tee-worker/identity/core/tls-websocket-server/src/certificate_generation.rs deleted file mode 100644 index 0a1afaaf0a..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/certificate_generation.rs +++ /dev/null @@ -1,172 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{error::WebSocketError, WebSocketResult}; -use bit_vec::BitVec; -use chrono::{prelude::*, TimeZone, Utc as TzUtc}; -use core::convert::TryFrom; -use rcgen::{date_time_ymd, Certificate, CertificateParams, DistinguishedName, DnType}; -use sp_core::{crypto::Pair, ed25519}; -use std::{ - string::ToString, - time::{SystemTime, UNIX_EPOCH}, - vec, - vec::Vec, -}; -use yasna::models::ObjectIdentifier; - -const ED25519: &[u64] = &[1, 3, 101, 112]; - -/// Create a sel-signed certificate, signed with the Ed25519 private key -/// Certificate Params are : -/// - alg: &PKCS_ED25519 -> ED25519 curve signing as per [RFC 8410](https://tools.ietf.org/html/rfc8410) -/// - common_name : the “subject”of the certificate, which is the identity of the certificate/website owner. -/// - not_before : now -/// - not_after : 4096-01-01 -> Certificate valid from initialisation time until 4096-01-01 -/// - serial_number : None, -/// - subject_alt_names : common_name. Required parameter. See below, subject -/// - DistinguishedName : -/// - issuer : Integritee, (The issuer field identifies the entity that has signed and issued the certificate. -/// The issuer field MUST contain a non-empty distinguished name (DN) ) -/// - subject: empty. (The subject field identifies the entity associated with the public key stored in the subject -/// public key field. If subject naming information is present only in the subjectAltName extension -/// (e.g., a key bound only to an email address or URI), then the subject name MUST be an empty sequence -/// and the subjectAltName extension MUST be critical. -/// - is_ca : SelfSignedOnly -> The certificate can only sign itself -/// - key_usages: empty (The key usage extension defines the purpose (e.g., encipherment, signature, certificate signing) of -/// the key contained in the certificate. The usage restriction might be employed when a key that could -/// be used for more than one operation is to be restricted.) -/// - extended_key_usages: empty ( This extension indicates one or more purposes for which the certified public key may be used, -/// in addition to or in place of the basic purposes indicated in the key usage extension.) -/// - name_constraints : None (only relevant for CA certificates) -/// - custom_extensions: None (The extensions defined for X.509 v3 certificates provide methods for associating additional -/// attributes with users or public keys and for managing relationships between CAs.) -/// - key_pair : rcgen::KeyPair from enclave private key. (A key pair used to sign certificates and CSRs) -/// - use_authority_key_identifier_extension: false (If `true` (and not self-signed), the 'Authority Key Identifier' extension will be added to the generated cert) -/// - key_identifier_method : KeyIdMethod::Sha256 (Method to generate key identifiers from public keys) - -pub fn ed25519_self_signed_certificate( - key_pair: ed25519::Pair, - common_name: &str, -) -> WebSocketResult { - let mut params = CertificateParams::new(vec![common_name.to_string()]); - let now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Error: UNIX_EPOCH"); - let issue_ts = TzUtc - .timestamp_opt(now.as_secs() as i64, 0) - .single() - .expect("Error: this should not fail as long as secs fit into i64"); - let year = issue_ts.year(); - let month = issue_ts.month(); - let day = issue_ts.day(); - params.not_before = date_time_ymd(year, month, day); - params.not_after = date_time_ymd(4096, 1, 1); - let mut dn = DistinguishedName::new(); - dn.push(DnType::OrganizationName, "Integritee"); - //dn.push(DnType::CommonName, common_name); - params.distinguished_name = dn; - - params.alg = &rcgen::PKCS_ED25519; //Signature Algorithm: - - let private_key_der = ed25519_private_key_pkcs8_der(key_pair)?; - - let key_pair = rcgen::KeyPair::try_from(private_key_der.as_ref()).expect("Invalid pkcs8 der"); - params.key_pair = Some(key_pair); - - Certificate::from_params(params).map_err(|e| WebSocketError::Other(e.into())) -} - -/// Generate the private key in a PKCS#8 format. To be compatible with rcgen lib. -/// PKCS#8 is specified in [RFC 5958]. -/// -/// [RFC 5958]: https://tools.ietf.org/html/rfc5958. -fn ed25519_private_key_pkcs8_der(key_pair: ed25519::Pair) -> WebSocketResult> { - let seed = key_pair.seed(); - let private_key = seed.as_slice(); - let pk = key_pair.public().0; - let public_key = pk.as_slice(); - let key_der = yasna::construct_der(|writer| { - writer.write_sequence(|writer| { - writer.next().write_u8(1); - // write OID - writer.next().write_sequence(|writer| { - writer.next().write_oid(&ObjectIdentifier::from_slice(ED25519)); - }); - let pk = yasna::construct_der(|writer| writer.write_bytes(private_key)); - writer.next().write_bytes(&pk); - writer.next().write_tagged(yasna::Tag::context(1), |writer| { - writer.write_bitvec(&BitVec::from_bytes(public_key)) - }) - }); - }); - Ok(key_der) -} - -#[cfg(test)] -mod tests { - use crate::certificate_generation::ed25519_self_signed_certificate; - use sp_core::{crypto::Pair, ed25519}; - use std::time::SystemTime; - use webpki::TLSServerTrustAnchors; - - type Seed = [u8; 32]; - const TEST_SEED: Seed = *b"12345678901234567890123456789012"; - - #[test] - pub fn test_verify_signature_self_signed_certificate() { - let signing = signer(); - let pk = signing.public().0; - let public_key = pk.as_slice(); - let cert = ed25519_self_signed_certificate(signing, "Test").unwrap(); - let sign_pub_key = cert.get_key_pair().public_key_raw(); - assert_eq!(public_key, sign_pub_key); - } - - #[test] - pub fn test_verify_is_valid_tls_server_certificate() { - let common_name = "Test"; - let signing = signer(); - let cert = ed25519_self_signed_certificate(signing, common_name).unwrap(); - - //write certificate and private key pem file - //let cert_der = cert.serialize_der().unwrap(); - //fs::write("test_cert.der", &cert_der).unwrap(); - - let cert_der = cert.serialize_der().unwrap(); - let end_entity_cert = webpki::EndEntityCert::from(&cert_der).unwrap(); - - let time = webpki::Time::try_from(SystemTime::now()); - - let trust_anchor = webpki::trust_anchor_util::cert_der_as_trust_anchor(&cert_der).unwrap(); - let trust_anchor_list = &[trust_anchor]; - let trust_anchors = TLSServerTrustAnchors(trust_anchor_list); - - assert!(end_entity_cert - .verify_is_valid_tls_server_cert( - &[&webpki::ED25519], - &trust_anchors, - &[], - time.unwrap(), - ) - .is_ok()); - } - - fn signer() -> ed25519::Pair { - ed25519::Pair::from_seed(&TEST_SEED) - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/config_provider.rs b/tee-worker/identity/core/tls-websocket-server/src/config_provider.rs deleted file mode 100644 index 04d561bc20..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/config_provider.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{error::WebSocketResult, tls_common::make_config}; -use rustls::ServerConfig; -use std::{string::String, sync::Arc}; - -/// Trait to provide a Rustls server config. -pub trait ProvideServerConfig: Send + Sync { - fn get_config(&self) -> WebSocketResult>; -} - -pub struct FromFileConfigProvider { - private_key: String, - certificate: String, -} - -impl FromFileConfigProvider { - pub fn new(private_key: String, certificate: String) -> Self { - Self { private_key, certificate } - } -} - -impl ProvideServerConfig for FromFileConfigProvider { - fn get_config(&self) -> WebSocketResult> { - make_config(&self.certificate, &self.private_key) - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/connection_id_generator.rs b/tee-worker/identity/core/tls-websocket-server/src/connection_id_generator.rs deleted file mode 100644 index dac5431cb6..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/connection_id_generator.rs +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{error::WebSocketError, WebSocketResult}; - -pub type ConnectionId = usize; - -/// Trait to generate IDs (nonce) for websocket connections. -pub trait GenerateConnectionId { - fn next_id(&self) -> WebSocketResult; -} - -pub struct ConnectionIdGenerator { - current_id: RwLock, -} - -const MIN_ID: usize = 10; - -impl Default for ConnectionIdGenerator { - fn default() -> Self { - Self { current_id: RwLock::new(MIN_ID) } - } -} - -impl GenerateConnectionId for ConnectionIdGenerator { - fn next_id(&self) -> WebSocketResult { - let mut id_lock = self.current_id.write().map_err(|_| WebSocketError::LockPoisoning)?; - *id_lock = id_lock.checked_add(1).unwrap_or(MIN_ID); - Ok(*id_lock) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::ws_server::{NEW_CONNECTIONS_LISTENER, SERVER_SIGNAL_TOKEN}; - - #[test] - fn next_id_works() { - let id_generator = ConnectionIdGenerator::default(); - - assert_eq!(11, id_generator.next_id().unwrap()); - assert_eq!(12, id_generator.next_id().unwrap()); - assert_eq!(13, id_generator.next_id().unwrap()); - } - - #[test] - fn next_id_is_greater_than_default_tokens() { - let id_generator = ConnectionIdGenerator::default(); - - let first_id = id_generator.next_id().unwrap(); - - assert!(NEW_CONNECTIONS_LISTENER < mio::Token(first_id)); - assert!(SERVER_SIGNAL_TOKEN < mio::Token(first_id)); - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/error.rs b/tee-worker/identity/core/tls-websocket-server/src/error.rs deleted file mode 100644 index 3d86b509dc..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/error.rs +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::ConnectionId; -use std::{boxed::Box, io::Error as IoError, net::AddrParseError, string::String}; - -pub type WebSocketResult = Result; - -/// General web-socket error type -#[derive(Debug, thiserror::Error)] -pub enum WebSocketError { - #[error("Invalid certificate: {0}")] - InvalidCertificate(String), - #[error("Invalid private key: {0}")] - InvalidPrivateKey(String), - #[error("Invalid web-socket address: {0}")] - InvalidWsAddress(AddrParseError), - #[error("TCP bind: {0}")] - TcpBindError(IoError), - #[error("Web-socket hand shake: {0}")] - HandShakeError(String), - #[error("{0} is not a valid and active web-socket connection id")] - InvalidConnection(ConnectionId), - #[error("Web-socket connection already closed error")] - ConnectionClosed, - #[error("Web-socket connection has not yet been established")] - ConnectionNotYetEstablished, - #[error("Web-socket write: {0}")] - SocketWriteError(String), - #[error("Lock poisoning")] - LockPoisoning, - #[error("Failed to receive server signal message: {0}")] - MioReceiveError(#[from] std::sync::mpsc::TryRecvError), - #[error("{0}")] - IoError(#[from] std::io::Error), - #[error("{0}")] - Other(Box), -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/stream_state.rs b/tee-worker/identity/core/tls-websocket-server/src/stream_state.rs deleted file mode 100644 index 17ebfbaceb..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/stream_state.rs +++ /dev/null @@ -1,166 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use log::*; -use rustls::{ServerSession, Session, StreamOwned}; -use std::{ - boxed::Box, - io::{Read, Result as IoResult, Write}, -}; -use tungstenite::{ - accept, - handshake::{server::NoCallback, MidHandshake}, - HandshakeError, ServerHandshake, WebSocket, -}; - -// similar to `tungstenite::stream::MaybeTlsStream`, but with a server side implementation -#[allow(clippy::large_enum_variant)] -pub(crate) enum MaybeServerTlsStream { - Plain(S), - Rustls(StreamOwned), -} - -impl MaybeServerTlsStream { - pub fn inner(&self) -> &S { - match self { - MaybeServerTlsStream::Plain(s) => s, - MaybeServerTlsStream::Rustls(s) => &s.sock, - } - } - - pub fn wants_read(&self) -> bool { - match self { - MaybeServerTlsStream::Plain(_) => true, - MaybeServerTlsStream::Rustls(s) => s.sess.wants_read(), - } - } - - pub fn wants_write(&self) -> bool { - match self { - MaybeServerTlsStream::Plain(_) => false, // do not monitor writable events for non-tls server - MaybeServerTlsStream::Rustls(s) => s.sess.wants_write(), - } - } -} - -impl Read for MaybeServerTlsStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult { - match *self { - MaybeServerTlsStream::Plain(ref mut s) => s.read(buf), - MaybeServerTlsStream::Rustls(ref mut s) => s.read(buf), - } - } -} - -impl Write for MaybeServerTlsStream { - fn write(&mut self, buf: &[u8]) -> IoResult { - match *self { - MaybeServerTlsStream::Plain(ref mut s) => s.write(buf), - MaybeServerTlsStream::Rustls(ref mut s) => s.write(buf), - } - } - - fn flush(&mut self) -> IoResult<()> { - match *self { - MaybeServerTlsStream::Plain(ref mut s) => s.flush(), - MaybeServerTlsStream::Rustls(ref mut s) => s.flush(), - } - } -} - -/// Internal stream state representing different websocket statuses -pub(crate) enum StreamState { - Invalid, - Initialized(Box>), - InHandshake(MidHandshake, NoCallback>>), - Established(Box>>), -} - -impl Default for StreamState { - fn default() -> Self { - Self::Invalid - } -} - -impl StreamState { - pub(crate) fn new_plain_stream(stream: S) -> Self { - StreamState::Initialized(Box::new(MaybeServerTlsStream::Plain(stream))) - } - - pub(crate) fn new_rustls_stream(session: ServerSession, stream: S) -> Self { - let s = StreamOwned::new(session, stream); - StreamState::Initialized(Box::new(MaybeServerTlsStream::Rustls(s))) - } - - pub(crate) fn is_invalid(&self) -> bool { - matches!(self, StreamState::Invalid) - } - - pub(crate) fn internal_stream(&self) -> Option<&MaybeServerTlsStream> { - match self { - StreamState::Initialized(s) => Some(s), - StreamState::InHandshake(h) => Some(h.get_ref().get_ref()), - StreamState::Established(ws) => Some(ws.get_ref()), - StreamState::Invalid => None, - } - } - - pub(crate) fn internal_stream_mut(&mut self) -> Option<&mut MaybeServerTlsStream> { - match self { - StreamState::Initialized(s) => Some(s), - StreamState::InHandshake(h) => Some(h.get_mut().get_mut()), - StreamState::Established(ws) => Some(ws.get_mut()), - StreamState::Invalid => None, - } - } - - pub(crate) fn attempt_handshake(self) -> Self { - match self { - // We have the bare TLS stream only, attempt to do a web-socket handshake. - StreamState::Initialized(s) => Self::from_handshake_result(accept(*s)), - // We already have an on-going handshake, attempt another try. - StreamState::InHandshake(hs) => Self::from_handshake_result(hs.handshake()), - _ => self, - } - } - - #[allow(clippy::type_complexity)] - fn from_handshake_result( - handshake_result: Result< - WebSocket>, - HandshakeError, NoCallback>>, - >, - ) -> Self { - match handshake_result { - Ok(ws) => Self::Established(Box::new(ws)), - Err(e) => match e { - // I/O would block our handshake attempt. Need to re-try. - HandshakeError::Interrupted(mhs) => { - info!("Web-socket handshake interrupted"); - Self::InHandshake(mhs) - }, - HandshakeError::Failure(e) => { - error!("Web-socket handshake failed: {:?}", e); - Self::Invalid - }, - }, - } - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/mod.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/mod.rs deleted file mode 100644 index 6790e464c8..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod no_cert_verifier; -pub mod test_cert; -pub mod test_private_key; -pub mod test_server; -pub mod test_server_config_provider; diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs deleted file mode 100644 index 50e05527ab..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/no_cert_verifier.rs +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 rustls::{Certificate, ClientCertVerified, DistinguishedNames, TLSError}; -use webpki::DNSName; - -/// Test Rustls verifier, disables ALL verification (do NOT use in production!) -pub struct NoCertVerifier {} - -impl rustls::ServerCertVerifier for NoCertVerifier { - fn verify_server_cert( - &self, - _: &rustls::RootCertStore, - _: &[rustls::Certificate], - _: webpki::DNSNameRef<'_>, - _: &[u8], - ) -> Result { - debug!("Certificate verification bypassed"); - Ok(rustls::ServerCertVerified::assertion()) - } -} - -impl rustls::ClientCertVerifier for NoCertVerifier { - fn client_auth_root_subjects(&self, _sni: Option<&DNSName>) -> Option { - None - } - - fn verify_client_cert( - &self, - _presented_certs: &[Certificate], - _sni: Option<&DNSName>, - ) -> Result { - debug!("Certificate verification bypassed"); - Ok(rustls::ClientCertVerified::assertion()) - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_cert.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_cert.rs deleted file mode 100644 index 1b94e7a24a..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_cert.rs +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 rustls::{internal::pemfile::certs, Certificate}; -use std::{io::BufReader, vec::Vec}; - -pub fn get_test_certificate_chain() -> Vec { - let mut buf_reader = BufReader::new(CERT_STR.as_bytes()); - certs(&mut buf_reader).unwrap() -} - -const CERT_STR: &str = "\ ------BEGIN CERTIFICATE----- -MIIEADCCAmigAwIBAgICAcgwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UEAwwhcG9u -eXRvd24gUlNBIGxldmVsIDIgaW50ZXJtZWRpYXRlMB4XDTE3MDQxMDIwNTYyN1oX -DTIyMTAwMTIwNTYyN1owGTEXMBUGA1UEAwwOdGVzdHNlcnZlci5jb20wggEiMA0G -CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCa4nonCxArES+kBBf9mZoaQ2GBMg74 -Pj2ve4RKJSIBt9A7EgJ4hFznFQ11O11Xvb3dVQGOK+pFRxh2xg0DJvV3lJytpvKe -mviyT5KSGvp6Hybqmx66B2V3iDfrXhhySqG5tKEeczFBIq+62dAp0+r0oSdpZKGT -1YDtXonjcbnDb93K7g8arEadFKYN3MAjBGQ3m5fsWJJuq4hLU1+dpmAfxmYH1dlc -n89LyPhYh0I7R5v17VrGlNCWIWD1emLtM8vTS94eMtp8R6MuMIZTOKgBTrIpU4G5 -GPcR3flDzzLsCxEttjjMa41zStKXzieUIwirRAzPv48V4JlkCCUPv97pAgMBAAGj -gb4wgbswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwHQYDVR0OBBYEFNn77YZg -4AGguHBKVggK00dtRvhCMEIGA1UdIwQ7MDmAFGuwcG2Zfyr92yAiXU9HP9rBYC6/ -oR6kHDAaMRgwFgYDVQQDDA9wb255dG93biBSU0EgQ0GCAXswOwYDVR0RBDQwMoIO -dGVzdHNlcnZlci5jb22CFXNlY29uZC50ZXN0c2VydmVyLmNvbYIJbG9jYWxob3N0 -MA0GCSqGSIb3DQEBCwUAA4IBgQB4xB9IPNxkJIA8QtngQZCCSPH5SjfAibcLfwi2 -NLHe4hO4HvoIVv0ru7CODfq45qNfH7sUj8a/JBU8BwcJ3xPewWFdavtCP8+dapmd -pr831+Xx6p9tNIdW16WrCXEV8i9bHy43Y4pWbNdXQy5meI0qvSM/ExedZqqVeJJT -oXL/aCtMsBixlwlKvrsG9ZvIAl1ics0wA5kqQWVufe95loI+HUcPc9s9689H+/ON -lH8rTLPwyufk9h2dTb9Wzw3qewlDIqgoyX7k9cOwrJqA4D6typCvb5dWfQlK9c72 -4rGbqHSx7mrlaZ4typfAMdEbynRlDSgIIZGXb7RaoV3NT2XuVFd8+lcXgBiJMvPk -STejz77EPR2+uKvQ1gMJXpEHCBUvMMyDqhpcNzb0DaXgf4eYI9RqfxU1pkgYnfxe -DGDGI2SdmO43NwSDyEQVSlRpCIBj4ZDay3IP7mbdi8MLxR9H1BCHnN7D04UrTnuA -c/cl0RMWL+iHtKU2cCxltEQQ9qQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIGnzCCAoegAwIBAgIBezANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9wb255 -dG93biBSU0EgQ0EwHhcNMTcwNDEwMjA1NjI3WhcNMjcwNDA4MjA1NjI3WjAsMSow -KAYDVQQDDCFwb255dG93biBSU0EgbGV2ZWwgMiBpbnRlcm1lZGlhdGUwggGiMA0G -CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDCX7V0gKGQBS64QKntjDlBslbQJaxq -EL8Yyq+qjF6nkOoqENKWSzeNyQ76kPVlzeV03UCaIgTF4+FeQrUr7wauEz0FGmDh -yx/B4xy9ZXdBIftPB8iz8Q/KrKO6YM6tkj7ijvL8hP3MfssBkA+VoAxamPSIikfM -9kyttemjYizgM0ywebzKmQGJbEINZ80Kp63ayR/Uo/cORjlH3xbmtTsL3pd+k6Ro -xOMZKm1RIwOwGgxDW4ea294A4lXHwfwHGMsP0/xmqTZ0R/EpxLKeqJAQffTiVsBK -YEFzANn3nol1IYrdcZcgcs16KTnc5+XyL87KSdIgDgG3wmQvRCdLX5G6GChyP03Z -qQSYMkwGSNgCD1v4m14Z5XT2su7iilHfjsucvT4OukCe63nqeXIZ+w63YqbjTp/a -HMgrXVg1wMlSncl0OIKcjLOgJ5vbPOGk9DvF93JbRFp/9sAZmK89Ur4gBmgpq2Zn -bknK0LVt+aerP7rf8CPYE89olPVUW0owwrkCAwEAAaNeMFwwHQYDVR0OBBYEFGuw -cG2Zfyr92yAiXU9HP9rBYC6/MCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEF -BQcDAjAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB/jANBgkqhkiG9w0BAQsFAAOC -BAEARD9wwIHsAFWlzrRLw3JcAUDB906Ks7KZzdqe3n6FkbyHHP1N5JG25wXwgADS -qux6sZU7h6+q209IEqXWbw+nbxJs/3D1hLN6X2tVgsfkSflGsd3DfNPZI8qKUyOD -VYlql/EPEMBixXOeVpwxXc48rX/yVjxqCvhY/A7eIiAc+bzQtwozLppChyVitQGI -MViXRdGdFiybwTKoJMYXl6ztamk9TWhdvJ9znirol12b06Z3J0Kz0c/kqY7VVZqL -ba76+IAJjvWQE7PYEOqpFHOLpilv9j5d/0kBR4AgJaooFwcYnr6aJKfNUgGWEmdn -ELYmfa0qORllAM/yGoewRfWGLZBNgT0QFYg2IFjnp0W0wIXFRd7xVqldN+cTmMqk -szpVV7bqGvuk6SQNFjIZ8VIVc/mXua4WlwBODDRzKqU3bIgBTODgVq1edwqp6UjN -ECLAOe1p03GGMr4WSPDoFjlQlHy+NLUwZg3RI+HsAkow9WfP7KqGN4vFDC4ru9Pg -2uD28oTrOgYQpzKjQJSH3kC5feOUdrsET7zic75XO1J33CAlgbIZ2TSQDqnH2cY5 -bQsWSNA2Lle3wBbeHlCy7ACiaoeJS23TJV9n8PcsRwSmHA9NgT4WSavXwtZ0lBhI -60GY80VXo9ziQjvVTMZNymZ4FEqCvULHGhFI08Jqd1jOXjnPLY4WEARqkicBJvI1 -3t4sBLDU+PEqH7m8k3lCZd6D7XVDcc8bJock+DjXZIMbZY79UMuzyHocXNJpRfRT -cqS0qneltFe6Pea7y0PN2IDttGBLb1CVQpXhRkpFU8jtyXh3ulSZSJEeqLVRFgdv -PVwHWAhLPewVGDkgTrlWVNfiXxp1LWVTFzQFas9xWiY4byQk/DNQaaFwHpGoZgVc -qAzUVk20Msm2u9xvSbPcBGk0dL4fdlnOkyeq/k/fnNrGdRHJWuJe7QR73/N0u6fy -7H76xUXvcwwrxL8ma8nV9K+A7oM7YUiR1wagD9cnoDDBgQmH9Izvfw0PxJgqnLOe -lQGPVGRhmXNtLLG57dqgjrvERGy9u5NMxBlkH0giZTFyQXPQ+N75ouM4S3RL75PM -UaTOBtnyCj++5ysnDFlGqEXgy08rrtkCbbNfd9dnO568juXS6ExC6TEL/pUMhy+Z -ooIJ69Tt7R5dOLaKRrkX/nKHfCfLfXXnjyDmdRHRYrXvTWusF038OsqY89tb0F0u -S4Szv4/Bl1bhzx/XYMZv/y7XL0va8FQLiRTuvqJ9hTsE/Xkd4ZFrP1LaP6HzVR1g -tsFs2Gc8j7H299U3WLjNon0TL2uPXa77Vu+9h7QCi1W9Uzsv0xMvZ/KMEnXyaEBd -W1lqo85ih1nnfxcW+lmAz8QNGQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIJCjCCBPKgAwIBAgIJAI+QZnVEkxq/MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNV -BAMMD3Bvbnl0b3duIFJTQSBDQTAeFw0xNzA0MTAyMDU2MjdaFw0yNzA0MDgyMDU2 -MjdaMBoxGDAWBgNVBAMMD3Bvbnl0b3duIFJTQSBDQTCCBCIwDQYJKoZIhvcNAQEB -BQADggQPADCCBAoCggQBAMD0iyFqRCNhvD5T9WXO8caNGb5ecrlnqSUvfcc+6Xh9 -sShtK6DX2DZ+6YT2WWOZTk0I9T+XG2kujjyfdCbEDMWcT9so7/gPeIG/qFlhONCu -HC+zntuZrGgMEYpF3Xc41CyF3saredTJEo1J64TPEke8mohezIGZYM1vTtRnqW+1 -RstSNTu8a/B0VaG0iA5P5RuSGVmxczi4EWJtuXFhcbgqICaUt0vJdrU0Fmrmq0Iq -ZEIpgZKYirx5QW8b6Q5tv0YsnXNasXvHZQve4GgF449ewk9wWfYevD8UttHUEe2a -QeEKb2l7NxqyY6trGyVtTRlm4SnoOH/9VodTKUEmS6pds6XFtjRflxgom0TL7CXb -uJ9b6fkXQlnf01FqAbv5HC1sjgGlSZc7Yk8k09nWOR8mZMoHC+U4KEq+oM+m87q4 -U/GsEk8UsPslGIIHHK6W/sdU6zA9bR3QYmkD40Z7FbVfKVvDmKPlwI7NONqysD8V -UTPoB8aE7FeulZhlTxdK2EcW14AsjbFiPQ4zAVxj4bRj39RLgJYL+BvAF6PfRHb1 -Xb7ykbuTvT7VhNYXLlQagR9EyixT3Wu9WCWUc0xJKSATn1s2YBLNM7LO4MkYO9WG -YrejhNHG+54a7rtnnlG04Gs7OhM32baMH/DxT+EEAX4j0Dfww4RaCZcfq1gDPsVe -+RzqsjjqF8+IzE25SK38xgwT/o3n9r5Ele3/zadwy695KCfbkhVFSDAPvhiv8um5 -6NNP+dDymFRXGzV85xSK75ue3Dpj+MoSScmIdGLEcU5EqYcBFLCXGLYPDIW8Lb89 -mG1z7TkZOLIs+6v7kp4rrvyijsyLFZ+EKUmabAK42qdzASZ1o6ETDDfFBETMxjWA -oMmGmRkhsyfBTuCr1ESlTBQHj4vvxBrgXgHtHwUinBw/sofLbkFRZ4wz/cBOtwqW -HIu88/o33l6ywMowcjaoToIbK2a4rD/KFJiwLliGKZG2veiESRhnNUQyjxT/PIef -0gqx3i1eBGWvfQs/wUC8qI5UadTRhjMFCwMCDVycevZE8lcQ+7zi9tVu6mXife5J -yP/jxRNDLzpdM6C6puqk0XieZey782XZ7sPpDpS2tphwakINF/5X3t1qZsssZPqq -F1S2VIsL8qm6Z7HDHXex3o2tDUhc226YSp/T7D+IWP3UCs0NjJrldakhnAd7ykxT -b2cDh09GDYSbji4Y6WmgIbSAurqk6kt4MWrfx4yfEAlp8ujH6788lRDAiXN1RgzC -k8r21IOJONDG7Qk1rS0YUV4XyGz4SEpBdPTI7RM1fl5bDn4e+OslBcfWh5XplZrz -4D4Z9YWVZ8X6d7CiPYZIg35oo/45KGel3Z8algziVkMCAwEAAaNTMFEwHQYDVR0O -BBYEFOWXlO0crUtBejJo87v9lwg8PlE6MB8GA1UdIwQYMBaAFOWXlO0crUtBejJo -87v9lwg8PlE6MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggQBADUQ -YqVmS9o3/5Qp7Tr+JL5ZNRP1fRmV5kAqaKDC5I9ONKRYahHvoI0ojE/j+pmwI4gf -mp5mW8EgsNfooovrzVSHxJgBO9r1ogMlL9AvwlvVxLbexvLXpM/1QjD/7FID/TaK -1q5mhSBKaEYXqQ+8DN25aVsI/bwHx4eP11Ft6YjhPqaX/WutE/IIAMbgASRFtBlO -foTm++fpdn8rCg5LiLLpWrRLC3zUSUtFd7if3wQ4vcDdck09v9PjD5Lk34aYkowJ -oARbVmBMpAxwkMXaThP1fT7xlYPDhAA26UXksT5xUNzFPbmOVReuFT0drhJlF6e6 -SLTjy2BcrYuz5ieBmmY6QboBYH3SzUFKuamvnHLSic3i3u9Ly68XUjOtDKgYB7Y5 -oZtfZT+YFmz/R6eLUcGRRfcmLJ+i/OXjgyKVkYBMDafW3RI9fRp46Yr/lvOv5gFW -Vrn3Tfc9cSbYQgE4vuKXcs4aVVeX8uAyjcucMV3eLdxaBLUAezTpJseRfqtH2kCk -3JIV6m2y6Tm5EhhaSiHKbe6FtPFKhpu7m9AlquUzhBU9Aq59mbKp6jtV0mWhYwKB -K6REmWQqqAOtHIs7UIXDeN1ZByJ7q+et57RvMgMHc5My0d6a+gQAUssH4i73sVTz -Uej57DW9L7hK0GQpzGzGIO/9lYTzWMVa8EZG1Fa5nUgMh3N3Oy6qUQIqr8E8xT2O -IbKKV6Acx6lBiwii4JkruEMgVVEdsDWDVdP8Ov5lJvvIPLWLqnXsZ2sKCyZrVkgc -PTXVtYBLmn7Tuwody2MSaBONSqleJ1oPQJ9lsAKyqX4xpX05ZJu2kNhST2oq2127 -378GS85DqKDM3P187mjU2G8moqWaGKr6byiIr7ea5TkqIzpC3tKW5QRHvX9aanz0 -akQx6F+l3l4L8J0cXaKasUJTaCk3cWPbbVzo8tQwwdxd0/MdJWrmitK85o+4gLqG -Cvn9VA4mnhjRR0XccxEtzmhSxBRWXoCF1+FnfDmXhPji+AmAhVqRwPkqX9T9H+54 -YG2ZA9Trxssme+QFSFCPZrHuw66ZI6GmKo6h+Hr2qew7LytASN+x2QyvRf7tSNmf -oUgmiD+CFpaH6exjrCC0/hcJ53Kv3E5GBvQskvOqgsUkW+nmsrm95YOosn+9MoQc -PIM6zQCmZ0N/6jHrEHnOnSnz03tGHsvPs6tMB6DKhQz9FNqlrLG7UHhlqhFWj9nv -H+Zh0oOwbcgcoxkk+W6LHLDpA3UpC1tlOzTlD2ektACvQQr/2A/fecpJN/7iWlX9 -BimWwRTS24bO5dX92Kb8V1TNO6ARd9TqOkPXRatysyh7it/MXpc5I2+t49hqlXoV -9Xpi4ds6s2cT8zZGDKI= ------END CERTIFICATE-----"; diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_private_key.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_private_key.rs deleted file mode 100644 index 0e3ad60d01..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_private_key.rs +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 rustls::{internal::pemfile::rsa_private_keys, PrivateKey}; -use std::io::BufReader; - -pub fn get_test_private_key() -> PrivateKey { - let mut buf_reader = BufReader::new(PRIVATE_KEY_STR.as_bytes()); - rsa_private_keys(&mut buf_reader).unwrap().first().unwrap().clone() -} - -const PRIVATE_KEY_STR: &str = "\ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAmuJ6JwsQKxEvpAQX/ZmaGkNhgTIO+D49r3uESiUiAbfQOxIC -eIRc5xUNdTtdV7293VUBjivqRUcYdsYNAyb1d5Scrabynpr4sk+Skhr6eh8m6pse -ugdld4g3614YckqhubShHnMxQSKvutnQKdPq9KEnaWShk9WA7V6J43G5w2/dyu4P -GqxGnRSmDdzAIwRkN5uX7FiSbquIS1NfnaZgH8ZmB9XZXJ/PS8j4WIdCO0eb9e1a -xpTQliFg9Xpi7TPL00veHjLafEejLjCGUzioAU6yKVOBuRj3Ed35Q88y7AsRLbY4 -zGuNc0rSl84nlCMIq0QMz7+PFeCZZAglD7/e6QIDAQABAoIBAQCEe5i08Nehnw+7 -Ie1LdSnFsUEj+6emW8bz5ZlguqZ+BbbN8DfA0qeM2gsq7d6IALr5KY8tBw9atteM -MRhMS/THloz2VMlPNYvpKftbkkwSTbdCEfGUemMmfZQnddM/X+s6J/FxVGMbLgpW -r51JSgW9vmMx2WwEQioH4EfeDxcwvZi3LF7SAo89eMSiSDqHZaIfMRmS0cSpoXav -u7gKDt7H+zSeYdLC4FhD4f8zRUpZEa4x5GIIm2JHsvIWuy9XKyepakaObJkWWqR1 -ATO94LtM2+RRVUev+yOVDDOfJtDzEqZrbokCHaVBYXgliAV/XkvFox1ZINyeGFq4 -kAvqfiQJAoGBAMhO/tAz2TpWeETMcujBekx1JmtDEUITJroDT0DvFDV5QRKVopxY -ZY5pPbwtk60KknBbsXrswR3Vh1q3xfKLT3Ln4x121ufltIwN7eopY9dXVqh830CU -QymtUz5VcvG3foWCeABcyklpZIdhHyDDDDP46URfFr3NnQiRnx7qb6yPAoGBAMXy -bSGgnBPUOWHtNW4hI5vxiOiCGWvCq7jERixybGMU8+kP6eRWUEAnOdCibq84A6gv -GLO5EW+bmL8l7L797w6ZN9DhbuR7W7hQVwdkyQS8PUgmTfsaba7+9hTC0chl+L38 -A7NlYRju+JS99SqarGA6WMvo30ykiMGwxw8tHOkHAoGAPT6Z/oK72nBx2WdBgxUV -FaeEFaut7Sv53UoBw3LWFPt7//isfW0xr/dRnuW4j2H6IEyI2XLmIP8WoZAq/9vE -cPeho3KghsrfByuDIOOC2Wak4mM7x30NhAKwvxBVUr6t+phHpKS6XPPSfuodIGFC -q+lhOTxxsZradrI/mq5HctUCgYEAqo4bYeIVGTC+0JWmd+Gt4OvYXx3Z8XOmqmjT -XfCpWyXuk13W1ZtZQi2KLy4F2IuW+w65ZgGL+HJExk5TEq2RkS6LXTsgZVW0zbbL -hd9dJOtckhIPFtDKuQGN3o2OW/EgxfGi7qvnYahmHyMdXzwuUitz3x4jaNJL0zgS -DA1+33kCgYA1iAZ58XXJPh6YObvw+kg21dCLLelxp+mCoRBSbY6wq+R6PmKg4a1N -oOc6Rh/1teyBVWJ/KnkXBeh9//XLfhg0r6zHDSCsDKabeM0eoB1AKWlc5f6bWYHV -60JHDgby+V1AElKT2yQT8KVv1hWJH4XQ1/fTQpQDDoo6O+nj1r4q6w== ------END RSA PRIVATE KEY-----"; diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server.rs deleted file mode 100644 index 11c92d8082..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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::{ - test::{ - fixtures::test_server_config_provider::TestServerConfigProvider, - mocks::web_socket_handler_mock::WebSocketHandlerMock, - }, - ws_server::TungsteniteWsServer, -}; -use std::{string::String, sync::Arc}; - -pub type TestServer = TungsteniteWsServer; - -pub fn create_server( - handler_responses: Vec, - port: u16, -) -> (Arc, Arc) { - let config_provider = Arc::new(TestServerConfigProvider {}); - let handler = Arc::new(WebSocketHandlerMock::from_response_sequence(handler_responses)); - - let server_addr_string = format!("127.0.0.1:{}", port); - - let server = Arc::new(TungsteniteWsServer::new( - server_addr_string, - Some(config_provider), - handler.clone(), - )); - (server, handler) -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs b/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs deleted file mode 100644 index 7f267aadf5..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/fixtures/test_server_config_provider.rs +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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_provider::ProvideServerConfig, - test::fixtures::{ - test_cert::get_test_certificate_chain, test_private_key::get_test_private_key, - }, - WebSocketResult, -}; -use rustls::{NoClientAuth, ServerConfig}; -use std::sync::Arc; - -pub struct TestServerConfigProvider; - -impl ProvideServerConfig for TestServerConfigProvider { - fn get_config(&self) -> WebSocketResult> { - let mut config = rustls::ServerConfig::new(NoClientAuth::new()); - - let certs = get_test_certificate_chain(); - let privkey = get_test_private_key(); - - config - .set_single_cert_with_ocsp_and_sct(certs, privkey, vec![], vec![]) - .unwrap(); - - Ok(Arc::new(config)) - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/mocks/mod.rs b/tee-worker/identity/core/tls-websocket-server/src/test/mocks/mod.rs deleted file mode 100644 index fd5dff2b6c..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/mocks/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod web_socket_connection_mock; -pub mod web_socket_handler_mock; diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs b/tee-worker/identity/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs deleted file mode 100644 index 26d9b3d61c..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/mocks/web_socket_handler_mock.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 = "sgx")] -use std::sync::SgxRwLock as RwLock; - -#[cfg(feature = "std")] -use std::sync::RwLock; - -use crate::{ConnectionToken, WebSocketMessageHandler, WebSocketResult}; -use log::debug; -use std::{collections::HashMap, string::String, vec::Vec}; - -pub struct WebSocketHandlerMock { - pub responses: Vec, - pub connection_message_indices: RwLock>, - pub messages_handled: RwLock>, -} - -impl WebSocketHandlerMock { - pub fn from_response_sequence(responses: Vec) -> Self { - WebSocketHandlerMock { - responses, - connection_message_indices: RwLock::default(), - messages_handled: Default::default(), - } - } - - pub fn get_handled_messages(&self) -> Vec<(ConnectionToken, String)> { - self.messages_handled.read().unwrap().clone() - } -} - -impl WebSocketMessageHandler for WebSocketHandlerMock { - fn handle_message( - &self, - connection_token: ConnectionToken, - message: String, - ) -> WebSocketResult> { - let mut handled_messages_lock = self.messages_handled.write().unwrap(); - - debug!("Handling message: {}", message); - handled_messages_lock.push((connection_token, message)); - - let mut connection_indices_lock = self.connection_message_indices.write().unwrap(); - - let message_index = connection_indices_lock.entry(connection_token).or_insert(0usize); - - let response = self.responses.get(*message_index).cloned(); - - *message_index += 1; - Ok(response) - } -} diff --git a/tee-worker/identity/core/tls-websocket-server/src/test/mod.rs b/tee-worker/identity/core/tls-websocket-server/src/test/mod.rs deleted file mode 100644 index 0d2c1da1d4..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/test/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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 mod fixtures; -pub mod mocks; diff --git a/tee-worker/identity/core/tls-websocket-server/src/tls_common.rs b/tee-worker/identity/core/tls-websocket-server/src/tls_common.rs deleted file mode 100644 index c2061abf87..0000000000 --- a/tee-worker/identity/core/tls-websocket-server/src/tls_common.rs +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed 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(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - -use crate::{error::WebSocketError, WebSocketResult}; -use rustls::NoClientAuth; -use std::{io::BufReader, string::ToString, sync::Arc, vec, vec::Vec}; - -pub fn make_config(cert: &str, key: &str) -> WebSocketResult> { - let mut config = rustls::ServerConfig::new(NoClientAuth::new()); - - let certs = load_certs(cert)?; - let privkey = load_private_key(key)?; - - config - .set_single_cert_with_ocsp_and_sct(certs, privkey, vec![], vec![]) - .expect("Invalid key der"); - - Ok(Arc::new(config)) -} - -fn load_certs(pem_content: &str) -> WebSocketResult> { - let mut reader = BufReader::new(pem_content.as_bytes()); - rustls::internal::pemfile::certs(&mut reader) - .map_err(|_| WebSocketError::InvalidCertificate("Failed to parse certificate".to_string())) -} - -fn load_private_key(pem_content: &str) -> WebSocketResult { - let rsa_keys = { - let mut reader = BufReader::new(pem_content.as_bytes()); - - rustls::internal::pemfile::rsa_private_keys(&mut reader).map_err(|_| { - WebSocketError::InvalidPrivateKey("Failed to parse RSA private key".to_string()) - })? - }; - - let pkcs8_keys = { - let mut reader = BufReader::new(pem_content.as_bytes()); - rustls::internal::pemfile::pkcs8_private_keys(&mut reader).map_err(|_| { - WebSocketError::InvalidPrivateKey( - "Invalid PKCS8 private key (encrypted keys are not supported)".to_string(), - ) - })? - }; - - // prefer to load pkcs8 keys - if !pkcs8_keys.is_empty() { - Ok(pkcs8_keys[0].clone()) - } else if !rsa_keys.is_empty() { - Ok(rsa_keys[0].clone()) - } else { - Err(WebSocketError::InvalidPrivateKey("No viable private keys were given".to_string())) - } -} diff --git a/tee-worker/identity/enclave-runtime/Cargo.lock b/tee-worker/identity/enclave-runtime/Cargo.lock index e589c28d07..34b8f1631d 100644 --- a/tee-worker/identity/enclave-runtime/Cargo.lock +++ b/tee-worker/identity/enclave-runtime/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", "log", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-primitives", "bitvec", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -271,9 +271,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" @@ -284,7 +290,7 @@ checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", ] @@ -454,6 +460,12 @@ dependencies = [ "scale-info", ] +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + [[package]] name = "byte-slice-cast" version = "1.2.2" @@ -829,6 +841,7 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", + "spki 0.7.3", ] [[package]] @@ -853,9 +866,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -863,6 +876,7 @@ dependencies = [ "ff", "generic-array 0.14.7", "group", + "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -880,15 +894,18 @@ dependencies = [ "frame-support", "frame-system", "hex", + "id-ita-parentchain-interface", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itc-direct-rpc-client", + "id-itc-direct-rpc-server", + "id-itc-offchain-worker-executor", + "id-itc-parentchain", + "id-itc-parentchain-block-import-dispatcher", + "id-itp-stf-executor", + "id-itp-top-pool", + "id-itp-top-pool-author", "ipfs-unixfs", - "ita-parentchain-interface", - "ita-sgx-runtime", - "ita-stf", - "itc-direct-rpc-client", - "itc-direct-rpc-server", - "itc-offchain-worker-executor", - "itc-parentchain", - "itc-parentchain-block-import-dispatcher", "itc-parentchain-test", "itc-peer-top-broadcaster", "itc-tls-websocket-server", @@ -908,7 +925,6 @@ dependencies = [ "itp-sgx-externalities", "itp-sgx-io", "itp-sgx-temp-dir", - "itp-stf-executor", "itp-stf-interface", "itp-stf-primitives", "itp-stf-state-handler", @@ -916,8 +932,6 @@ dependencies = [ "itp-storage", "itp-test", "itp-time-utils", - "itp-top-pool", - "itp-top-pool-author", "itp-types", "itp-utils", "its-block-verification", @@ -1305,7 +1319,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "hex", "libsecp256k1", @@ -1338,7 +1352,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "evm 0.39.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support", @@ -1366,7 +1380,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -1394,7 +1408,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bitflags", "environmental 1.1.4", @@ -1424,7 +1438,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "cfg-expr", @@ -1440,7 +1454,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1452,7 +1466,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -1462,7 +1476,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "log", @@ -1764,7 +1778,7 @@ dependencies = [ [[package]] name = "hashbrown_tstd" version = "0.12.0" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "heck" @@ -1811,7 +1825,7 @@ dependencies = [ [[package]] name = "http" version = "0.2.1" -source = "git+https://github.com/integritee-network/http-sgx.git?branch=sgx-experimental#307b5421fb7a489a114bede0dc05c8d32b804f49" +source = "git+https://github.com/integritee-network/http-sgx?branch=sgx-experimental#307b5421fb7a489a114bede0dc05c8d32b804f49" dependencies = [ "bytes 1.0.1", "fnv 1.0.6", @@ -1850,125 +1864,12 @@ dependencies = [ ] [[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.2.0" -source = "git+https://github.com/mesalock-linux/rust-url-sgx?tag=sgx_1.1.3#23832f3191456c2d4a0faab10952e1747be58ca8" -dependencies = [ - "matches", - "sgx_tstd", - "unicode-bidi 0.3.4", - "unicode-normalization 0.1.12", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" -dependencies = [ - "unicode-bidi 0.3.15", - "unicode-normalization 0.1.23", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde 1.0.204", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote 1.0.36", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.6.1" -source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" -dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.9.1", - "sgx_tstd", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits 0.2.16", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" -dependencies = [ - "sgx_libc", -] - -[[package]] -name = "ipfs-unixfs" -version = "0.0.1" -source = "git+https://github.com/whalelephant/rust-ipfs?branch=w-nstd#52f84dceea7065bb4ee2c24da53b3bedf162241a" -dependencies = [ - "cid", - "either", - "multihash", - "quick-protobuf", - "sha2 0.9.9", -] - -[[package]] -name = "ita-parentchain-interface" +name = "id-ita-parentchain-interface" version = "0.1.0" dependencies = [ - "ita-sgx-runtime", - "ita-stf", - "itc-parentchain-indirect-calls-executor", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itc-parentchain-indirect-calls-executor", "itp-api-client-types", "itp-enclave-metrics", "itp-node-api", @@ -1987,7 +1888,7 @@ dependencies = [ ] [[package]] -name = "ita-sgx-runtime" +name = "id-ita-sgx-runtime" version = "0.1.0" dependencies = [ "frame-executive", @@ -1995,7 +1896,7 @@ dependencies = [ "frame-system", "itp-sgx-runtime-primitives", "pallet-balances", - "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", + "pallet-evm 6.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", "pallet-identity-management-tee", "pallet-parentchain", "pallet-sudo", @@ -2011,14 +1912,14 @@ dependencies = [ ] [[package]] -name = "ita-stf" +name = "id-ita-stf" version = "0.1.0" dependencies = [ "frame-support", "frame-system", "hex", "hex-literal", - "ita-sgx-runtime", + "id-ita-sgx-runtime", "itp-hashing", "itp-node-api", "itp-node-api-metadata", @@ -2048,7 +1949,7 @@ dependencies = [ ] [[package]] -name = "itc-direct-rpc-client" +name = "id-itc-direct-rpc-client" version = "0.1.0" dependencies = [ "itp-rpc", @@ -2064,7 +1965,7 @@ dependencies = [ ] [[package]] -name = "itc-direct-rpc-server" +name = "id-itc-direct-rpc-server" version = "0.1.0" dependencies = [ "itc-tls-websocket-server", @@ -2081,16 +1982,16 @@ dependencies = [ ] [[package]] -name = "itc-offchain-worker-executor" +name = "id-itc-offchain-worker-executor" version = "0.1.0" dependencies = [ + "id-itp-stf-executor", + "id-itp-top-pool-author", "itc-parentchain-light-client", "itp-extrinsics-factory", - "itp-stf-executor", "itp-stf-interface", "itp-stf-primitives", "itp-stf-state-handler", - "itp-top-pool-author", "itp-types", "log", "parity-scale-codec", @@ -2100,12 +2001,12 @@ dependencies = [ ] [[package]] -name = "itc-parentchain" +name = "id-itc-parentchain" version = "0.1.0" dependencies = [ - "itc-parentchain-block-import-dispatcher", - "itc-parentchain-block-importer", - "itc-parentchain-indirect-calls-executor", + "id-itc-parentchain-block-import-dispatcher", + "id-itc-parentchain-block-importer", + "id-itc-parentchain-indirect-calls-executor", "itc-parentchain-light-client", "itp-types", "parity-scale-codec", @@ -2113,10 +2014,10 @@ dependencies = [ ] [[package]] -name = "itc-parentchain-block-import-dispatcher" +name = "id-itc-parentchain-block-import-dispatcher" version = "0.1.0" dependencies = [ - "itc-parentchain-block-importer", + "id-itc-parentchain-block-importer", "itp-import-queue", "log", "sgx_tstd", @@ -2125,16 +2026,16 @@ dependencies = [ ] [[package]] -name = "itc-parentchain-block-importer" +name = "id-itc-parentchain-block-importer" version = "0.1.0" dependencies = [ - "ita-stf", - "itc-parentchain-indirect-calls-executor", + "id-ita-stf", + "id-itc-parentchain-indirect-calls-executor", + "id-itp-stf-executor", "itc-parentchain-light-client", "itp-enclave-metrics", "itp-extrinsics-factory", "itp-ocall-api", - "itp-stf-executor", "itp-stf-interface", "itp-types", "log", @@ -2146,20 +2047,22 @@ dependencies = [ ] [[package]] -name = "itc-parentchain-indirect-calls-executor" +name = "id-itc-parentchain-indirect-calls-executor" version = "0.1.0" dependencies = [ "binary-merkle-tree", + "bs58", "futures 0.3.8", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-api-client-types", "itp-enclave-metrics", "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", - "itp-stf-executor", + "itp-sgx-runtime-primitives", "itp-stf-primitives", "itp-test", - "itp-top-pool-author", "itp-types", "litentry-primitives", "log", @@ -2171,6 +2074,190 @@ dependencies = [ "thiserror", ] +[[package]] +name = "id-itp-stf-executor" +version = "0.1.0" +dependencies = [ + "hex", + "id-itp-top-pool-author", + "itc-parentchain-test", + "itp-enclave-metrics", + "itp-node-api", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-sgx-externalities", + "itp-stf-interface", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-stf-state-observer", + "itp-test", + "itp-time-utils", + "itp-types", + "log", + "parity-scale-codec", + "sgx_tstd", + "sgx_types", + "sp-core", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "id-itp-top-pool" +version = "0.1.0" +dependencies = [ + "byteorder 1.4.3", + "derive_more", + "id-itc-direct-rpc-server", + "itp-stf-primitives", + "itp-types", + "its-primitives", + "jsonrpc-core", + "linked-hash-map", + "log", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "id-itp-top-pool-author" +version = "0.1.0" +dependencies = [ + "derive_more", + "id-itp-top-pool", + "itp-enclave-metrics", + "itp-ocall-api", + "itp-sgx-crypto", + "itp-stf-primitives", + "itp-stf-state-handler", + "itp-test", + "itp-types", + "itp-utils", + "jsonrpc-core", + "lazy_static", + "litentry-primitives", + "log", + "parity-scale-codec", + "sgx_tstd", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx?tag=sgx_1.1.3#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "matches", + "sgx_tstd", + "unicode-bidi 0.3.4", + "unicode-normalization 0.1.12", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "git+https://github.com/domenukk/rust-url?branch=no_std#316c8683206f3cb741163779bb30963fa05b3612" +dependencies = [ + "unicode-bidi 0.3.15", + "unicode-normalization 0.1.23", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde 1.0.204", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote 1.0.36", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" +dependencies = [ + "autocfg 1.1.0", + "hashbrown 0.9.1", + "sgx_tstd", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits 0.2.16", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/iovec-sgx#5c2f8e81925b4c06c556d856f3237461b00e27c9" +dependencies = [ + "sgx_libc", +] + +[[package]] +name = "ipfs-unixfs" +version = "0.0.1" +source = "git+https://github.com/whalelephant/rust-ipfs?branch=w-nstd#52f84dceea7065bb4ee2c24da53b3bedf162241a" +dependencies = [ + "cid", + "either", + "multihash", + "quick-protobuf", + "sha2 0.9.9", +] + [[package]] name = "itc-parentchain-light-client" version = "0.1.0" @@ -2204,8 +2291,8 @@ dependencies = [ name = "itc-peer-top-broadcaster" version = "0.1.0" dependencies = [ - "itc-direct-rpc-client", - "itc-direct-rpc-server", + "id-itc-direct-rpc-client", + "id-itc-direct-rpc-server", "itp-rpc", "itp-stf-primitives", "itp-types", @@ -2240,7 +2327,7 @@ dependencies = [ "mio", "mio-extras", "rcgen", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "sgx_tstd", "sp-core", "thiserror", @@ -2308,7 +2395,7 @@ dependencies = [ "log", "num-bigint", "parity-scale-codec", - "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", + "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?tag=sgx_1.1.3)", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_rand", "sgx_tcrypto", @@ -2334,7 +2421,6 @@ dependencies = [ name = "itp-enclave-metrics" version = "0.1.0" dependencies = [ - "lc-stf-task-sender", "litentry-primitives", "parity-scale-codec", "sgx_tstd", @@ -2459,11 +2545,14 @@ version = "0.1.0" dependencies = [ "aes", "derive_more", + "hex", "itp-sgx-io", "itp-sgx-temp-dir", + "k256", "log", "ofb", "parity-scale-codec", + "secp256k1 0.28.0", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_crypto_helper", "sgx_rand", @@ -2512,34 +2601,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "itp-stf-executor" -version = "0.1.0" -dependencies = [ - "hex", - "itc-parentchain-test", - "itp-enclave-metrics", - "itp-node-api", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-sgx-externalities", - "itp-stf-interface", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-stf-state-observer", - "itp-test", - "itp-time-utils", - "itp-top-pool-author", - "itp-types", - "log", - "parity-scale-codec", - "sgx_tstd", - "sgx_types", - "sp-core", - "sp-runtime", - "thiserror", -] - [[package]] name = "itp-stf-interface" version = "0.8.0" @@ -2652,49 +2713,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "itp-top-pool" -version = "0.1.0" -dependencies = [ - "byteorder 1.4.3", - "derive_more", - "itc-direct-rpc-server", - "itp-stf-primitives", - "itp-types", - "its-primitives", - "jsonrpc-core", - "linked-hash-map", - "log", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "itp-top-pool-author" -version = "0.1.0" -dependencies = [ - "derive_more", - "itp-enclave-metrics", - "itp-ocall-api", - "itp-sgx-crypto", - "itp-stf-primitives", - "itp-stf-state-handler", - "itp-test", - "itp-top-pool", - "itp-types", - "itp-utils", - "jsonrpc-core", - "lazy_static", - "litentry-primitives", - "log", - "parity-scale-codec", - "sgx_tstd", - "sp-core", - "sp-runtime", -] - [[package]] name = "itp-types" version = "0.1.0" @@ -2708,6 +2726,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "serde 1.0.204", + "sp-consensus-grandpa", "sp-core", "sp-runtime", "sp-std", @@ -2727,14 +2746,14 @@ dependencies = [ name = "its-block-composer" version = "0.1.0" dependencies = [ + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-node-api", "itp-settings", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-time-utils", - "itp-top-pool-author", "itp-types", "its-primitives", "its-state", @@ -2768,19 +2787,19 @@ name = "its-consensus-aura" version = "0.1.0" dependencies = [ "finality-grandpa", - "ita-stf", - "itc-parentchain-block-import-dispatcher", + "id-ita-stf", + "id-itc-parentchain-block-import-dispatcher", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itc-peer-top-broadcaster", "itp-enclave-metrics", "itp-ocall-api", "itp-settings", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", "itp-time-utils", - "itp-top-pool-author", "itp-types", "its-block-composer", "its-block-verification", @@ -2861,10 +2880,10 @@ name = "its-rpc-handler" version = "0.1.0" dependencies = [ "futures 0.3.8", + "id-itp-top-pool-author", "itp-import-queue", "itp-rpc", "itp-stf-primitives", - "itp-top-pool-author", "itp-types", "itp-utils", "its-primitives", @@ -2937,14 +2956,15 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2 0.10.7", + "signature", ] [[package]] @@ -2990,7 +3010,6 @@ dependencies = [ "lc-data-providers", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", - "lc-stf-task-sender", "litentry-primitives", "log", "pallet-parachain-staking", @@ -3019,7 +3038,6 @@ dependencies = [ "lc-common", "lc-credentials-v2", "lc-service", - "lc-stf-task-sender", "litentry-hex-utils 0.1.0", "litentry-primitives", "log", @@ -3075,7 +3093,7 @@ dependencies = [ name = "lc-data-providers" version = "0.1.0" dependencies = [ - "base64 0.22.0", + "base64 0.13.1", "chrono 0.4.11", "http", "http_req", @@ -3132,7 +3150,7 @@ dependencies = [ name = "lc-identity-verification" version = "0.1.0" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "frame-support", "futures 0.3.8", "hex", @@ -3143,7 +3161,6 @@ dependencies = [ "itp-utils", "lazy_static", "lc-data-providers", - "lc-stf-task-sender", "litentry-primitives", "log", "lru", @@ -3197,16 +3214,16 @@ dependencies = [ "frame-support", "futures 0.3.8", "hex", - "ita-sgx-runtime", - "ita-stf", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-enclave-metrics", "itp-ocall-api", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", - "itp-top-pool-author", "itp-types", "itp-utils", "lc-assertion-build", @@ -3255,18 +3272,18 @@ version = "0.1.0" dependencies = [ "frame-support", "futures 0.3.8", - "ita-sgx-runtime", - "ita-stf", + "id-ita-sgx-runtime", + "id-ita-stf", + "id-itp-stf-executor", + "id-itp-top-pool-author", "itp-enclave-metrics", "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", "itp-sgx-externalities", - "itp-stf-executor", "itp-stf-primitives", "itp-stf-state-handler", "itp-storage", - "itp-top-pool-author", "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", @@ -3384,6 +3401,7 @@ dependencies = [ "core-primitives", "hex", "itp-sgx-crypto", + "itp-sgx-runtime-primitives", "log", "pallet-teebag", "parity-scale-codec", @@ -3714,7 +3732,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3728,7 +3746,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3742,11 +3760,11 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" +source = "git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42#a5a5e1e6ec08cd542a6084c310863150fb8841b1" dependencies = [ "evm 0.39.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fp-account 1.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", - "fp-evm 3.0.0-dev (git+https://github.com/integritee-network/frontier.git?branch=bar/polkadot-v0.9.42)", + "fp-account 1.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", + "fp-evm 3.0.0-dev (git+https://github.com/integritee-network/frontier?branch=bar/polkadot-v0.9.42)", "frame-support", "frame-system", "hex", @@ -3838,7 +3856,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3858,7 +3876,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3899,7 +3917,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3915,7 +3933,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -3929,9 +3947,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -3993,6 +4011,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.3", +] + [[package]] name = "postcard" version = "0.7.3" @@ -4541,9 +4569,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" +checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -4600,6 +4628,7 @@ dependencies = [ "base16ct", "der 0.7.8", "generic-array 0.14.7", + "pkcs8", "subtle", "zeroize", ] @@ -4750,12 +4779,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_backtrace_sys" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "cc", "sgx_build_helper", @@ -4765,7 +4794,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_crypto_helper" @@ -4784,12 +4813,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" [[package]] name = "sgx_libc" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_types", ] @@ -4849,7 +4878,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_trts", "sgx_types", @@ -4915,7 +4944,7 @@ source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master [[package]] name = "sgx_unwind" version = "1.1.6" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#3c903bdac4e503dd27b9b1f761c4abfc55f2464c" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?branch=master#1b1d03376056321441ef99716aa0888bd5ef19f7" dependencies = [ "sgx_build_helper", ] @@ -5049,7 +5078,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "log", "parity-scale-codec", @@ -5065,7 +5094,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "blake2", @@ -5079,7 +5108,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5091,7 +5120,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "integer-sqrt", "num-traits 0.2.16", @@ -5104,7 +5133,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "finality-grandpa", "log", @@ -5120,7 +5149,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5131,7 +5160,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", "bitflags", @@ -5162,7 +5191,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "blake2b_simd 1.0.2", "byteorder 1.4.3", @@ -5176,7 +5205,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -5187,7 +5216,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote 1.0.36", @@ -5197,7 +5226,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "environmental 1.1.4", "parity-scale-codec", @@ -5208,7 +5237,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -5232,7 +5261,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -5243,7 +5272,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "either", "hash256-std-hasher", @@ -5263,7 +5292,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.5.0", "impl-trait-for-tuples", @@ -5281,7 +5310,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "proc-macro-crate", @@ -5293,7 +5322,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5306,7 +5335,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5318,12 +5347,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "ref-cast", @@ -5334,7 +5363,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -5345,7 +5374,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-std", @@ -5356,7 +5385,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "memory-db", @@ -5371,7 +5400,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5384,7 +5413,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -5395,7 +5424,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -5405,7 +5434,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -5431,6 +5460,16 @@ dependencies = [ "der 0.6.1", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der 0.7.8", +] + [[package]] name = "ss58-registry" version = "1.43.0" @@ -5479,7 +5518,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" dependencies = [ "ac-compose-macros", "ac-node-api", @@ -5978,7 +6017,7 @@ dependencies = [ "const-oid", "der 0.6.1", "flagset", - "spki", + "spki 0.6.0", ] [[package]] @@ -6042,9 +6081,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] diff --git a/tee-worker/identity/enclave-runtime/Cargo.toml b/tee-worker/identity/enclave-runtime/Cargo.toml index a1c5d356e7..283d1fcedf 100644 --- a/tee-worker/identity/enclave-runtime/Cargo.toml +++ b/tee-worker/identity/enclave-runtime/Cargo.toml @@ -99,44 +99,44 @@ cid = { default-features = false, git = "https://github.com/whalelephant/rust-ci multibase = { default-features = false, git = "https://github.com/whalelephant/rust-multibase", branch = "nstd" } # local deps -ita-parentchain-interface = { path = "../app-libs/parentchain-interface", default-features = false, features = ["sgx"] } -ita-sgx-runtime = { path = "../app-libs/sgx-runtime", default-features = false } -ita-stf = { path = "../app-libs/stf", default-features = false, features = ["sgx"] } -itc-direct-rpc-client = { path = "../core/direct-rpc-client", default-features = false, features = ["sgx"] } -itc-direct-rpc-server = { path = "../core/direct-rpc-server", default-features = false, features = ["sgx"] } -itc-offchain-worker-executor = { path = "../core/offchain-worker-executor", default-features = false, features = ["sgx"] } -itc-parentchain = { path = "../core/parentchain/parentchain-crate", default-features = false, features = ["sgx"] } -itc-parentchain-block-import-dispatcher = { path = "../core/parentchain/block-import-dispatcher", default-features = false, features = ["sgx"] } -itc-parentchain-test = { path = "../core/parentchain/test", default-features = false } +ita-parentchain-interface = { package = "id-ita-parentchain-interface", path = "../app-libs/parentchain-interface", default-features = false, features = ["sgx"] } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../app-libs/sgx-runtime", default-features = false } +ita-stf = { package = "id-ita-stf", path = "../app-libs/stf", default-features = false, features = ["sgx"] } +itc-direct-rpc-client = { package = "id-itc-direct-rpc-client", path = "../core/direct-rpc-client", default-features = false, features = ["sgx"] } +itc-direct-rpc-server = { package = "id-itc-direct-rpc-server", path = "../core/direct-rpc-server", default-features = false, features = ["sgx"] } +itc-offchain-worker-executor = { package = "id-itc-offchain-worker-executor", path = "../core/offchain-worker-executor", default-features = false, features = ["sgx"] } +itc-parentchain = { package = "id-itc-parentchain", path = "../core/parentchain/parentchain-crate", default-features = false, features = ["sgx"] } +itc-parentchain-block-import-dispatcher = { package = "id-itc-parentchain-block-import-dispatcher", path = "../core/parentchain/block-import-dispatcher", default-features = false, features = ["sgx"] } +itc-parentchain-test = { path = "../../common/core/parentchain/test", default-features = false } itc-peer-top-broadcaster = { path = "../core/peer-top-broadcaster", default-features = false, features = ["sgx"] } -itc-tls-websocket-server = { path = "../core/tls-websocket-server", default-features = false, features = ["sgx"] } -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-enclave-metrics = { path = "../core-primitives/enclave-metrics", default-features = false, features = ["sgx"] } -itp-extrinsics-factory = { path = "../core-primitives/extrinsics-factory", default-features = false, features = ["sgx"] } -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 } -itp-nonce-cache = { path = "../core-primitives/nonce-cache", default-features = false, features = ["sgx"] } -itp-ocall-api = { path = "../core-primitives/ocall-api", default-features = false } -itp-primitives-cache = { path = "../core-primitives/primitives-cache", default-features = false, features = ["sgx"] } -itp-rpc = { path = "../core-primitives/rpc", default-features = false, features = ["sgx"] } -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-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"] } -itp-top-pool-author = { path = "../core-primitives/top-pool-author", default-features = false, features = ["sgx"] } -itp-types = { path = "../core-primitives/types", default-features = false } -itp-utils = { path = "../core-primitives/utils", default-features = false } +itc-tls-websocket-server = { path = "../../common/core/tls-websocket-server", default-features = false, features = ["sgx"] } +itp-attestation-handler = { path = "../../common/core-primitives/attestation-handler", default-features = false, features = ["sgx"] } +itp-component-container = { path = "../../common/core-primitives/component-container", default-features = false, features = ["sgx"] } +itp-enclave-metrics = { path = "../../common/core-primitives/enclave-metrics", default-features = false, features = ["sgx"] } +itp-extrinsics-factory = { path = "../../common/core-primitives/extrinsics-factory", default-features = false, features = ["sgx"] } +itp-import-queue = { path = "../../common/core-primitives/import-queue", default-features = false, features = ["sgx"] } +itp-node-api = { path = "../../common/core-primitives/node-api", default-features = false, features = ["sgx"] } +itp-node-api-metadata = { path = "../../common/core-primitives/node-api/metadata", default-features = false } +itp-nonce-cache = { path = "../../common/core-primitives/nonce-cache", default-features = false, features = ["sgx"] } +itp-ocall-api = { path = "../../common/core-primitives/ocall-api", default-features = false } +itp-primitives-cache = { path = "../../common/core-primitives/primitives-cache", default-features = false, features = ["sgx"] } +itp-rpc = { path = "../../common/core-primitives/rpc", default-features = false, features = ["sgx"] } +itp-settings = { path = "../../common/core-primitives/settings" } +itp-sgx-crypto = { path = "../../common/core-primitives/sgx/crypto", default-features = false, features = ["sgx"] } +itp-sgx-externalities = { path = "../../common/core-primitives/substrate-sgx/externalities", default-features = false, features = ["sgx"] } +itp-sgx-io = { path = "../../common/core-primitives/sgx/io", default-features = false, features = ["sgx"] } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../core-primitives/stf-executor", default-features = false, features = ["sgx"] } +itp-stf-interface = { path = "../../common/core-primitives/stf-interface", default-features = false } +itp-stf-primitives = { path = "../../common/core-primitives/stf-primitives", default-features = false } +itp-stf-state-handler = { path = "../../common/core-primitives/stf-state-handler", default-features = false, features = ["sgx"] } +itp-stf-state-observer = { path = "../../common/core-primitives/stf-state-observer", default-features = false, features = ["sgx"] } +itp-storage = { path = "../../common/core-primitives/storage", default-features = false, features = ["sgx"] } +itp-test = { path = "../../common/core-primitives/test", default-features = false, optional = true } +itp-time-utils = { path = "../../common/core-primitives/time-utils", default-features = false, features = ["sgx"] } +itp-top-pool = { package = "id-itp-top-pool", path = "../core-primitives/top-pool", default-features = false, features = ["sgx"] } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../core-primitives/top-pool-author", default-features = false, features = ["sgx"] } +itp-types = { path = "../../common/core-primitives/types", default-features = false } +itp-utils = { path = "../../common/core-primitives/utils", default-features = false } its-block-verification = { path = "../sidechain/block-verification", default-features = false } its-primitives = { path = "../sidechain/primitives", default-features = false } @@ -147,22 +147,22 @@ its-sidechain = { path = "../sidechain/sidechain-crate", default-features = fals lc-data-providers = { path = "../litentry/core/data-providers", default-features = false, features = ["sgx"] } lc-evm-dynamic-assertions = { path = "../litentry/core/evm-dynamic-assertions", default-features = false, features = ["sgx"] } lc-identity-verification = { path = "../litentry/core/identity-verification", default-features = false, features = ["sgx"] } -lc-parachain-extrinsic-task-receiver = { path = "../litentry/core/parachain-extrinsic-task/receiver", default-features = false, features = ["sgx"] } +lc-parachain-extrinsic-task-receiver = { path = "../../common/litentry/core/parachain-extrinsic-task/receiver", default-features = false, features = ["sgx"] } lc-stf-task-receiver = { path = "../litentry/core/stf-task/receiver", default-features = false, features = ["sgx"] } lc-vc-task-receiver = { path = "../litentry/core/vc-task/receiver", default-features = false, features = ["sgx"] } litentry-hex-utils = { path = "../../../common/utils/hex", default-features = false } litentry-macros = { path = "../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../litentry/primitives", default-features = false, features = ["sgx"] } +litentry-primitives = { path = "../../common/litentry/primitives", default-features = false, features = ["sgx"] } litentry-proc-macros = { path = "../../../common/primitives/core/proc-macros", default-features = false } # substrate deps -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, optional = true } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["full_crypto"] } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } # test-deps -itp-sgx-temp-dir = { version = "0.1", default-features = false, optional = true, path = "../core-primitives/sgx/temp-dir" } +itp-sgx-temp-dir = { path = "../../common/core-primitives/sgx/temp-dir", default-features = false, optional = true } [patch.crates-io] env_logger = { git = "https://github.com/integritee-network/env_logger-sgx" } @@ -173,7 +173,7 @@ ring = { git = "https://github.com/betrusted-io/ring-xous", branch = "0.16.20-cl log = { git = "https://github.com/integritee-network/log-sgx" } [patch."https://github.com/paritytech/substrate"] -sp-io = { path = "../core-primitives/substrate-sgx/sp-io" } +sp-io = { path = "../../common/core-primitives/substrate-sgx/sp-io" } [patch."https://github.com/apache/teaclave-sgx-sdk.git"] sgx_alloc = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } diff --git a/tee-worker/identity/enclave-runtime/src/initialization/mod.rs b/tee-worker/identity/enclave-runtime/src/initialization/mod.rs index 35e6eb6128..dabe50920b 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/mod.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/mod.rs @@ -102,7 +102,7 @@ pub(crate) fn init_enclave( untrusted_worker_url: String, base_dir: PathBuf, ) -> EnclaveResult<()> { - let signing_key_repository = Arc::new(get_ed25519_repository(base_dir.clone())?); + let signing_key_repository = Arc::new(get_ed25519_repository(base_dir.clone(), None, None)?); GLOBAL_SIGNING_KEY_REPOSITORY_COMPONENT.initialize(signing_key_repository.clone()); let signer = signing_key_repository.retrieve_key()?; info!("[Enclave initialized] Ed25519 prim raw : {:?}", signer.public().0); diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs index c6ffc09512..62e7bb6d67 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_parachain.rs @@ -36,12 +36,11 @@ use crate::{ use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; +use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; -use itp_stf_interface::ShardCreationInfo; - #[derive(Clone)] pub struct IntegriteeParachainHandler { pub genesis_header: ParachainHeader, diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs index e2fbe60ced..f8c8d512d7 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/integritee_solochain.rs @@ -36,12 +36,11 @@ use crate::{ use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; +use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; -use itp_stf_interface::ShardCreationInfo; - pub struct IntegriteeSolochainHandler { pub genesis_header: SolochainHeader, pub node_metadata_repository: Arc, diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/mod.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/mod.rs index 4926e957cd..8ac2ae9928 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/mod.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/mod.rs @@ -38,12 +38,10 @@ use crate::{ use codec::{Decode, Encode}; use integritee_parachain::IntegriteeParachainHandler; use integritee_solochain::IntegriteeSolochainHandler; -use itc_parentchain::{ - light_client::{concurrent_access::ValidatorAccess, LightClientState}, - primitives::{ParentchainId, ParentchainInitParams}, -}; +use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; use itp_component_container::ComponentInitializer; use itp_settings::worker_mode::ProvideWorkerMode; +use itp_types::parentchain::{ParentchainId, ParentchainInitParams}; use log::*; use std::{path::PathBuf, vec::Vec}; diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs index 03e35f250c..59921c14af 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_parachain.rs @@ -38,11 +38,11 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; #[derive(Clone)] diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs index 87b4c53b1e..41a12bbbf8 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_a_solochain.rs @@ -32,11 +32,11 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; pub struct TargetASolochainHandler { diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs index eb87049e47..21b729a456 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_parachain.rs @@ -38,11 +38,11 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{ParachainBlock, ParachainHeader, ParachainParams}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{ParachainBlock, ParachainHeader, ParachainParams}; use std::{path::PathBuf, sync::Arc}; #[derive(Clone)] diff --git a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs index ae2cf688d8..954fe436c8 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/parentchain/target_b_solochain.rs @@ -32,11 +32,11 @@ use crate::{ }, }; use itc_parentchain::light_client::{concurrent_access::ValidatorAccess, LightClientState}; -pub use itc_parentchain::primitives::{SolochainBlock, SolochainHeader, SolochainParams}; use itp_component_container::ComponentGetter; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerMode}; use itp_stf_interface::ShardCreationInfo; use itp_types::parentchain::ParentchainId; +pub use itp_types::parentchain::{SolochainBlock, SolochainHeader, SolochainParams}; use std::{path::PathBuf, sync::Arc}; pub struct TargetBSolochainHandler { diff --git a/tee-worker/identity/enclave-runtime/src/lib.rs b/tee-worker/identity/enclave-runtime/src/lib.rs index f66fc256cf..9531f372da 100644 --- a/tee-worker/identity/enclave-runtime/src/lib.rs +++ b/tee-worker/identity/enclave-runtime/src/lib.rs @@ -63,7 +63,6 @@ use core::ffi::c_int; use itc_parentchain::{ block_import_dispatcher::DispatchBlockImport, light_client::{concurrent_access::ValidatorAccess, Validator}, - primitives::ParentchainId, }; use itp_component_container::ComponentGetter; @@ -73,7 +72,7 @@ use itp_nonce_cache::{MutateNonce, Nonce}; use itp_settings::worker_mode::{ProvideWorkerMode, WorkerModeProvider}; use itp_sgx_crypto::key_repository::AccessPubkey; use itp_storage::{StorageProof, StorageProofChecker}; -use itp_types::{ShardIdentifier, SignedBlock}; +use itp_types::{parentchain::ParentchainId, ShardIdentifier, SignedBlock}; use itp_utils::write_slice_and_whitespace_pad; use litentry_macros::if_development_or; use log::*; diff --git a/tee-worker/identity/enclave-runtime/src/ocall/on_chain_ocall.rs b/tee-worker/identity/enclave-runtime/src/ocall/on_chain_ocall.rs index 95b9183269..e80c1fb112 100644 --- a/tee-worker/identity/enclave-runtime/src/ocall/on_chain_ocall.rs +++ b/tee-worker/identity/enclave-runtime/src/ocall/on_chain_ocall.rs @@ -19,10 +19,11 @@ use crate::ocall::{ffi, OcallApi}; use codec::{Decode, Encode}; use frame_support::ensure; -use itc_parentchain::primitives::ParentchainId; use itp_ocall_api::{EnclaveOnChainOCallApi, Result}; use itp_storage::{verify_storage_entries, Error as StorageError}; -use itp_types::{storage::StorageEntryVerified, WorkerRequest, WorkerResponse, H256}; +use itp_types::{ + parentchain::ParentchainId, storage::StorageEntryVerified, WorkerRequest, WorkerResponse, H256, +}; use log::*; use sgx_types::*; use sp_runtime::{traits::Header, OpaqueExtrinsic}; diff --git a/tee-worker/identity/enclave-runtime/src/test/mocks/propose_to_import_call_mock.rs b/tee-worker/identity/enclave-runtime/src/test/mocks/propose_to_import_call_mock.rs index fa47ae9539..7f68b55a69 100644 --- a/tee-worker/identity/enclave-runtime/src/test/mocks/propose_to_import_call_mock.rs +++ b/tee-worker/identity/enclave-runtime/src/test/mocks/propose_to_import_call_mock.rs @@ -18,13 +18,12 @@ use crate::test::mocks::types::TestBlockImporter; use codec::{Decode, Encode}; -use itc_parentchain::primitives::ParentchainId; use itp_ocall_api::{ EnclaveMetricsOCallApi, EnclaveOnChainOCallApi, EnclaveSidechainOCallApi, Result, }; use itp_types::{ - storage::StorageEntryVerified, BlockHash, Header as ParentchainHeader, ShardIdentifier, - WorkerRequest, WorkerResponse, H256, + parentchain::ParentchainId, storage::StorageEntryVerified, BlockHash, + Header as ParentchainHeader, ShardIdentifier, WorkerRequest, WorkerResponse, H256, }; use its_primitives::types::block::SignedBlock as SignedSidechainBlockType; use its_sidechain::consensus_common::BlockImport; diff --git a/tee-worker/identity/litentry/core/assertion-build-v2/Cargo.toml b/tee-worker/identity/litentry/core/assertion-build-v2/Cargo.toml index 3c5593ba7c..e9bebb6ee4 100644 --- a/tee-worker/identity/litentry/core/assertion-build-v2/Cargo.toml +++ b/tee-worker/identity/litentry/core/assertion-build-v2/Cargo.toml @@ -4,40 +4,31 @@ edition = "2021" name = "lc-assertion-build-v2" version = "0.1.0" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -base58 = { version = "0.2", default-features = false } -thiserror = { version = "1.0.38", optional = true } - -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } - -# internal dependencies -itc-rest-client = { path = "../../../core/rest-client", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-stf-primitives = { default-features = false, path = "../../../core-primitives/stf-primitives" } -itp-types = { path = "../../../core-primitives/types", default-features = false } -itp-utils = { path = "../../../core-primitives/utils", default-features = false } - -# litentry -lc-assertion-build = { path = "../assertion-build", default-features = false } -lc-common = { path = "../common", default-features = false } -lc-credentials-v2 = { path = "../credentials-v2", default-features = false } -lc-service = { path = "../service", default-features = false } -lc-stf-task-sender = { path = "../stf-task/sender", default-features = false } -litentry-hex-utils = { path = "../../../../../common/utils/hex", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +base58 = { workspace = true } +thiserror = { workspace = true, optional = true } + +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } + +itc-rest-client = { workspace = true } +itp-ocall-api = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } + +lc-assertion-build = { workspace = true } +lc-common = { workspace = true } +lc-credentials-v2 = { workspace = true } +lc-service = { workspace = true } +litentry-hex-utils = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -env_logger = "0.10.0" -lc-mock-server = { path = "../mock-server" } +env_logger = { workspace = true } +lc-mock-server = { workspace = true } [features] default = ["std"] @@ -49,7 +40,6 @@ sgx = [ "lc-assertion-build/sgx", "lc-credentials-v2/sgx", "lc-service/sgx", - "lc-stf-task-sender/sgx", ] std = [ "log/std", @@ -60,5 +50,4 @@ std = [ "lc-assertion-build/std", "lc-credentials-v2/std", "lc-service/std", - "lc-stf-task-sender/std", ] diff --git a/tee-worker/identity/litentry/core/assertion-build-v2/src/linked_identities/mod.rs b/tee-worker/identity/litentry/core/assertion-build-v2/src/linked_identities/mod.rs index 0e925a4a3a..a5b5d1cd0f 100644 --- a/tee-worker/identity/litentry/core/assertion-build-v2/src/linked_identities/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build-v2/src/linked_identities/mod.rs @@ -23,7 +23,7 @@ extern crate sgx_tstd as std; use lc_credentials_v2::{ linked_identities::LinkedIdentitiesAssertionUpdate, Credential, IssuerRuntimeVersion, }; -use lc_stf_task_sender::AssertionBuildRequest; +use litentry_primitives::AssertionBuildRequest; use crate::*; diff --git a/tee-worker/identity/litentry/core/assertion-build-v2/src/nft_holder/mod.rs b/tee-worker/identity/litentry/core/assertion-build-v2/src/nft_holder/mod.rs index adfaef31d0..e8009bbeb0 100644 --- a/tee-worker/identity/litentry/core/assertion-build-v2/src/nft_holder/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build-v2/src/nft_holder/mod.rs @@ -22,8 +22,7 @@ extern crate sgx_tstd as std; use lc_credentials_v2::{nft_holder::NFTHolderAssertionUpdate, Credential, IssuerRuntimeVersion}; use lc_service::web3_nft::nft_holder::has_nft; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::{Web3Network, Web3NftType}; +use litentry_primitives::{AssertionBuildRequest, Web3Network, Web3NftType}; use log::debug; use crate::*; diff --git a/tee-worker/identity/litentry/core/assertion-build-v2/src/platform_user/mod.rs b/tee-worker/identity/litentry/core/assertion-build-v2/src/platform_user/mod.rs index a4c5725c8b..14d68d4e0a 100644 --- a/tee-worker/identity/litentry/core/assertion-build-v2/src/platform_user/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build-v2/src/platform_user/mod.rs @@ -26,8 +26,7 @@ use lc_credentials_v2::{ platform_user::PlatformUserAssertionUpdate, Credential, IssuerRuntimeVersion, }; use lc_service::platform_user::is_user; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::{PlatformUserType, Web3Network}; +use litentry_primitives::{AssertionBuildRequest, PlatformUserType, Web3Network}; use log::debug; use crate::*; diff --git a/tee-worker/identity/litentry/core/assertion-build-v2/src/token_holding_amount/mod.rs b/tee-worker/identity/litentry/core/assertion-build-v2/src/token_holding_amount/mod.rs index cdca9d0e88..0ab3206a8b 100644 --- a/tee-worker/identity/litentry/core/assertion-build-v2/src/token_holding_amount/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build-v2/src/token_holding_amount/mod.rs @@ -24,8 +24,7 @@ use lc_credentials_v2::{ token_holding_amount::TokenHoldingAmountAssertionUpdate, Credential, IssuerRuntimeVersion, }; use lc_service::web3_token::token_balance::get_token_balance; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::{Web3Network, Web3TokenType}; +use litentry_primitives::{AssertionBuildRequest, Web3Network, Web3TokenType}; use log::debug; use crate::*; diff --git a/tee-worker/identity/litentry/core/assertion-build/Cargo.toml b/tee-worker/identity/litentry/core/assertion-build/Cargo.toml index 10c6ae1001..09fc7d1fda 100644 --- a/tee-worker/identity/litentry/core/assertion-build/Cargo.toml +++ b/tee-worker/identity/litentry/core/assertion-build/Cargo.toml @@ -4,61 +4,50 @@ edition = "2021" name = "lc-assertion-build" version = "0.1.0" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -blake2-rfc = { version = "0.2.18", default-features = false } -http = { version = "0.2", optional = true } -http_req = { optional = true, features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } -rust-base58 = { package = "rust-base58", version = "0.0.4", optional = true } -ss58-registry = { version = "1.40", default-features = false } - -# sgx dependencies -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -http_req-sgx = { optional = true, default-features = false, features = ["rust-tls", "sgx"], package = "http_req", git = "https://github.com/integritee-network/http_req" } -rust-base58-sgx = { git = "https://github.com/mesalock-linux/rust-base58-sgx", optional = true, package = "rust-base58", features = ["mesalock_sgx"] } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } - -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false } -log = { version = "0.4", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } - -primitive-types = { version = "0.12.1", default-features = false } +blake2-rfc = { workspace = true } +http = { workspace = true, optional = true } +http_req = { workspace = true, optional = true } +rust-base58 = { workspace = true, optional = true } +ss58-registry = { workspace = true } -# internal dependencies -itc-rest-client = { path = "../../../core/rest-client", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-stf-primitives = { default-features = false, path = "../../../core-primitives/stf-primitives" } -itp-types = { path = "../../../core-primitives/types", default-features = false } -itp-utils = { path = "../../../core-primitives/utils", default-features = false } +http-sgx = { workspace = true, optional = true } +http_req-sgx = { workspace = true, optional = true } +rust-base58-sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +log = { workspace = true } +primitive-types = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +itc-rest-client = { workspace = true } +itp-ocall-api = { workspace = true } +itp-stf-primitives = { workspace = true } +itp-types = { workspace = true } +itp-utils = { workspace = true } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-support = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } -# litentry -lc-common = { path = "../common", default-features = false } -lc-credentials = { path = "../credentials", default-features = false } -lc-data-providers = { path = "../data-providers", default-features = false } -lc-dynamic-assertion = { path = "../dynamic-assertion", default-features = false } -lc-evm-dynamic-assertions = { path = "../evm-dynamic-assertions", default-features = false } -lc-stf-task-sender = { path = "../stf-task/sender", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } -pallet-parachain-staking = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } +lc-common = { workspace = true } +lc-credentials = { workspace = true } +lc-data-providers = { workspace = true } +lc-dynamic-assertion = { workspace = true } +lc-evm-dynamic-assertions = { workspace = true } +litentry-primitives = { workspace = true } +pallet-parachain-staking = { workspace = true } [dev-dependencies] -chrono = { version = "0.4.19", default-features = false, features = ["alloc"] } -env_logger = "0.10.0" -lc-mock-server = { path = "../mock-server" } -litentry-hex-utils = { path = "../../../../../common/utils/hex" } +chrono = { workspace = true, features = ["std", "alloc"] } +env_logger = { workspace = true } +lc-mock-server = { workspace = true } +litentry-hex-utils = { workspace = true } ethabi = { version = "18.0.0", default-features = false } -itp-test = { path = "../../../core-primitives/test", default-features = false } +itp-test = { workspace = true } [features] default = ["std"] @@ -70,7 +59,6 @@ sgx = [ "sgx_tstd", "thiserror_sgx", "litentry-primitives/sgx", - "lc-stf-task-sender/sgx", "lc-common/sgx", "lc-credentials/sgx", "lc-data-providers/sgx", @@ -91,7 +79,6 @@ std = [ "itp-utils/std", "frame-support/std", "litentry-primitives/std", - "lc-stf-task-sender/std", "lc-common/std", "lc-credentials/std", "lc-data-providers/std", diff --git a/tee-worker/identity/litentry/core/assertion-build/src/achainable/class_of_year.rs b/tee-worker/identity/litentry/core/assertion-build/src/achainable/class_of_year.rs index 90e1a1ecc8..8c558f8b8c 100644 --- a/tee-worker/identity/litentry/core/assertion-build/src/achainable/class_of_year.rs +++ b/tee-worker/identity/litentry/core/assertion-build/src/achainable/class_of_year.rs @@ -23,8 +23,7 @@ extern crate sgx_tstd as std; use crate::{achainable::request_achainable_classofyear, *}; use lc_credentials::{Credential, IssuerRuntimeVersion}; use lc_data_providers::DataProviderConfig; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::{AchainableClassOfYear, AchainableParams}; +use litentry_primitives::{AchainableClassOfYear, AchainableParams, AssertionBuildRequest}; use log::debug; const VC_SUBJECT_DESCRIPTION: &str = diff --git a/tee-worker/identity/litentry/core/assertion-build/src/achainable/mod.rs b/tee-worker/identity/litentry/core/assertion-build/src/achainable/mod.rs index 581e672b48..20477105ab 100644 --- a/tee-worker/identity/litentry/core/assertion-build/src/achainable/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build/src/achainable/mod.rs @@ -35,8 +35,7 @@ use lc_data_providers::{ achainable_names::{AchainableNameAmountToken, GetAchainableName}, DataProviderConfig, Error as DataProviderError, LIT_TOKEN_ADDRESS, }; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::AchainableParams; +use litentry_primitives::{AchainableParams, AssertionBuildRequest}; use std::string::ToString; pub mod amount; diff --git a/tee-worker/identity/litentry/core/assertion-build/src/dynamic/mod.rs b/tee-worker/identity/litentry/core/assertion-build/src/dynamic/mod.rs index 4330bda8b3..b5f984531a 100644 --- a/tee-worker/identity/litentry/core/assertion-build/src/dynamic/mod.rs +++ b/tee-worker/identity/litentry/core/assertion-build/src/dynamic/mod.rs @@ -20,7 +20,7 @@ use itp_types::Assertion; use lc_credentials::{assertion_logic::AssertionLogic, Credential, IssuerRuntimeVersion}; use lc_dynamic_assertion::{AssertionExecutor, AssertionLogicRepository}; use lc_evm_dynamic_assertions::EvmAssertionExecutor; -use lc_stf_task_sender::AssertionBuildRequest; +use litentry_primitives::AssertionBuildRequest; use log::error; use primitive_types::H160; @@ -91,10 +91,10 @@ pub mod assertion_test { use itp_test::mock::metrics_ocall_mock::MetricsOCallMock; use itp_types::Assertion; use lc_mock_server::run; - use lc_stf_task_sender::AssertionBuildRequest; use litentry_hex_utils::decode_hex; use litentry_primitives::{ - DynamicContractParams, DynamicParams, Identity, IdentityString, Web3Network, + AssertionBuildRequest, DynamicContractParams, DynamicParams, Identity, IdentityString, + Web3Network, }; use sp_core::{crypto::AccountId32, H160}; use std::sync::Arc; diff --git a/tee-worker/identity/litentry/core/assertion-build/src/generic_discord_role.rs b/tee-worker/identity/litentry/core/assertion-build/src/generic_discord_role.rs index 60c7321f86..a581a86358 100644 --- a/tee-worker/identity/litentry/core/assertion-build/src/generic_discord_role.rs +++ b/tee-worker/identity/litentry/core/assertion-build/src/generic_discord_role.rs @@ -28,8 +28,9 @@ use lc_credentials::{ use lc_data_providers::{ discord_litentry::DiscordLitentryClient, DataProviderConfig, Error as DataProviderError, }; -use lc_stf_task_sender::AssertionBuildRequest; -use litentry_primitives::{ContestType, GenericDiscordRoleType, SoraQuizType}; +use litentry_primitives::{ + AssertionBuildRequest, ContestType, GenericDiscordRoleType, SoraQuizType, +}; use std::string::ToString; pub fn build( diff --git a/tee-worker/identity/litentry/core/assertion-build/src/lib.rs b/tee-worker/identity/litentry/core/assertion-build/src/lib.rs index dfd715a233..5c4e88e240 100644 --- a/tee-worker/identity/litentry/core/assertion-build/src/lib.rs +++ b/tee-worker/identity/litentry/core/assertion-build/src/lib.rs @@ -58,14 +58,13 @@ use itp_types::AccountId; use itp_utils::stringify::{account_id_to_string, account_id_to_string_without_prefix}; use lc_credentials::Credential; use lc_data_providers::achainable::web3_network_to_chain; -use lc_stf_task_sender::AssertionBuildRequest; use litentry_primitives::{ p2pkh_address, p2sh_address, p2tr_address, p2wpkh_address, AchainableAmount, AchainableAmountHolding, AchainableAmountToken, AchainableAmounts, AchainableBasic, AchainableBetweenPercents, AchainableDate, AchainableDateInterval, AchainableDatePercent, - AchainableParams, AchainableToken, Assertion, DynamicParams, ErrorDetail, ErrorString, - Identity, IdentityNetworkTuple, IntoErrorDetail, OneBlockCourseType, ParameterString, - VCMPError as Error, Web3Network, + AchainableParams, AchainableToken, Assertion, AssertionBuildRequest, DynamicParams, + ErrorDetail, ErrorString, Identity, IdentityNetworkTuple, IntoErrorDetail, OneBlockCourseType, + ParameterString, VCMPError as Error, Web3Network, }; use log::*; use rust_base58::ToBase58; diff --git a/tee-worker/identity/litentry/core/common/Cargo.toml b/tee-worker/identity/litentry/core/common/Cargo.toml index a3cbf6f988..425bbe0f15 100644 --- a/tee-worker/identity/litentry/core/common/Cargo.toml +++ b/tee-worker/identity/litentry/core/common/Cargo.toml @@ -4,13 +4,8 @@ name = "lc-common" version = "0.1.0" [dependencies] -# std dependencies - -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } - -# Internal dependencies -litentry-primitives = { path = "../../primitives", default-features = false } +litentry-primitives = { workspace = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/credentials-v2/Cargo.toml b/tee-worker/identity/litentry/core/credentials-v2/Cargo.toml index 5b37093a22..59ddda8a25 100644 --- a/tee-worker/identity/litentry/core/credentials-v2/Cargo.toml +++ b/tee-worker/identity/litentry/core/credentials-v2/Cargo.toml @@ -5,13 +5,11 @@ name = "lc-credentials-v2" version = "0.1.0" [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# litentry -lc-common = { path = "../common", default-features = false } -lc-credentials = { path = "../credentials", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +lc-common = { workspace = true } +lc-credentials = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/credentials/Cargo.toml b/tee-worker/identity/litentry/core/credentials/Cargo.toml index 73869ee20a..e57deff367 100644 --- a/tee-worker/identity/litentry/core/credentials/Cargo.toml +++ b/tee-worker/identity/litentry/core/credentials/Cargo.toml @@ -5,37 +5,32 @@ name = "lc-credentials" version = "0.1.0" [dependencies] -# std dependencies -chrono = { version = "0.4.19", default-features = false, features = ["alloc"] } -rust-base58 = { package = "rust-base58", version = "0.0.4", optional = true } -scale-info = { version = "2.4.0", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.38", optional = true } +chrono = { workspace = true } +rust-base58 = { workspace = true, optional = true } +scale-info = { workspace = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -rand-sgx = { package = "rand", git = "https://github.com/mesalock-linux/rand-sgx", tag = "sgx_1.1.3", features = ["sgx_tstd"], optional = true } -rust-base58-sgx = { git = "https://github.com/mesalock-linux/rust-base58-sgx", optional = true, package = "rust-base58", features = ["mesalock_sgx"] } -serde_json_sgx = { package = "serde_json", tag = "sgx_1.1.3", git = "https://github.com/mesalock-linux/serde-json-sgx", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +chrono_sgx = { workspace = true, optional = true } +rand-sgx = { workspace = true, optional = true } +rust-base58-sgx = { workspace = true, optional = true } +serde_json_sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -rand = { version = "0.7", optional = true } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +rand = { workspace = true, optional = true } +serde = { workspace = true } +serde_json = { workspace = true } -# internal dependencies -itp-stf-primitives = { default-features = false, path = "../../../core-primitives/stf-primitives" } -itp-time-utils = { path = "../../../core-primitives/time-utils", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } +itp-stf-primitives = { workspace = true } +itp-time-utils = { workspace = true } +itp-types = { workspace = true } +sp-core = { workspace = true } -# litentry -lc-common = { path = "../common", default-features = false } -lc-data-providers = { path = "../data-providers", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +lc-common = { workspace = true } +lc-data-providers = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/data-providers/Cargo.toml b/tee-worker/identity/litentry/core/data-providers/Cargo.toml index 93da1ad233..16aead1920 100644 --- a/tee-worker/identity/litentry/core/data-providers/Cargo.toml +++ b/tee-worker/identity/litentry/core/data-providers/Cargo.toml @@ -4,41 +4,35 @@ edition = "2021" name = "lc-data-providers" version = "0.1.0" - [dependencies] -# std dependencies -base64 = { version = "0.22", default-features = false, features = ["alloc"] } -chrono = { version = "0.4.19", features = ["alloc"], optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -http = { version = "0.2", optional = true } -http_req = { optional = true, features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } -thiserror = { version = "1.0.26", optional = true } +base64 = { workspace = true } +chrono = { workspace = true, optional = true } +codec = { package = "parity-scale-codec", workspace = true } +http = { workspace = true, optional = true } +http_req = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } -# no_std dependencies -log = { version = "0.4", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } +log = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } -# internal dependencies -itc-rest-client = { path = "../../../core/rest-client", default-features = false } -itp-rpc = { path = "../../../core-primitives/rpc", default-features = false } +itc-rest-client = { workspace = true } +itp-rpc = { workspace = true } -# sgx dependencies -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -http_req-sgx = { package = "http_req", git = "https://github.com/integritee-network/http_req", default-features = false, features = ["rust-tls", "sgx"], optional = true } -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +chrono_sgx = { workspace = true, optional = true } +http-sgx = { workspace = true, optional = true } +http_req-sgx = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# litentry -lc-common = { path = "../common", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +lc-common = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -env_logger = "0.10.0" -lc-mock-server = { path = "../mock-server" } -itp-stf-primitives = { path = "../../../core-primitives/stf-primitives" } +env_logger = { workspace = true } +lc-mock-server = { workspace = true } +itp-stf-primitives = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/data-providers/src/twitter_official.rs b/tee-worker/identity/litentry/core/data-providers/src/twitter_official.rs index b1689165d6..4d9da3af42 100644 --- a/tee-worker/identity/litentry/core/data-providers/src/twitter_official.rs +++ b/tee-worker/identity/litentry/core/data-providers/src/twitter_official.rs @@ -18,7 +18,6 @@ use crate::sgx_reexport_prelude::*; use crate::{build_client_with_cert, vec_to_string, Error, HttpError, UserInfo}; -use base64::engine::{general_purpose::STANDARD as BASE64_STANDARD, Engine}; use http::header::{AUTHORIZATION, CONNECTION}; use http_req::response::Headers; use itc_rest_client::{ @@ -183,7 +182,7 @@ impl TwitterOfficialClient { } pub fn oauth2_authorization(client_id: &str, client_secret: &str) -> String { - format!("Basic {}", BASE64_STANDARD.encode(format!("{}:{}", client_id, client_secret))) + format!("Basic {}", base64::encode(format!("{}:{}", client_id, client_secret))) } /// V2, rate limit: 300/15min(per App) 900/15min(per User) diff --git a/tee-worker/identity/litentry/core/dynamic-assertion/Cargo.toml b/tee-worker/identity/litentry/core/dynamic-assertion/Cargo.toml index 63c1563cf9..98a370d787 100644 --- a/tee-worker/identity/litentry/core/dynamic-assertion/Cargo.toml +++ b/tee-worker/identity/litentry/core/dynamic-assertion/Cargo.toml @@ -4,15 +4,9 @@ version = "0.1.0" authors = ['Trust Computing GmbH '] edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -#local -litentry-primitives = { path = "../../primitives", default-features = false } - -# sgx -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } - +litentry-primitives = { workspace = true } +sgx_tstd = { workspace = true, optional = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/evm-dynamic-assertions/Cargo.toml b/tee-worker/identity/litentry/core/evm-dynamic-assertions/Cargo.toml index a1a18fa908..ac902f9730 100644 --- a/tee-worker/identity/litentry/core/evm-dynamic-assertions/Cargo.toml +++ b/tee-worker/identity/litentry/core/evm-dynamic-assertions/Cargo.toml @@ -4,47 +4,41 @@ version = "0.1.0" authors = ['Trust Computing GmbH '] edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependecies -base58 = { version = "0.2", default-features = false } -blake2-rfc = { version = "0.2.18", default-features = false } -chrono = { version = "0.4.26", default-features = true, optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -http = { version = "0.2", optional = true } +base58 = { workspace = true } +blake2-rfc = { workspace = true } +chrono = { workspace = true, optional = true } +codec = { package = "parity-scale-codec", workspace = true } +http = { workspace = true, optional = true } rust_decimal = { version = "1.35.0", default-features = false } -ss58-registry = { version = "1.40", default-features = false } -thiserror = { version = "1.0.26", optional = true } +ss58-registry = { workspace = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -chrono_sgx = { package = "chrono", git = "https://github.com/mesalock-linux/chrono-sgx", optional = true } -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -itp-sgx-temp-dir = { version = "0.1", default-features = false, path = "../../../core-primitives/sgx/temp-dir", optional = true } -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -thiserror-sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +chrono_sgx = { workspace = true, optional = true } +http-sgx = { workspace = true, optional = true } +itp-sgx-temp-dir = { workspace = true, optional = true } +sgx_tstd = { workspace = true, optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no std ethabi = { version = "18.0.0", default-features = false } evm = { version = "0.41.1", default-features = false, features = ["with-codec"] } -hex = { version = "0.4.3", default-features = false } -log = { version = "0.4", default-features = false } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +hex = { workspace = true } +log = { workspace = true } +serde_json = { workspace = true } -# local -itc-rest-client = { path = "../../../core/rest-client", default-features = false } -itp-enclave-metrics = { path = "../../../core-primitives/enclave-metrics", default-features = false } -itp-ocall-api = { path = "../../../core-primitives/ocall-api", default-features = false } -itp-settings = { path = "../../../core-primitives/settings" } -itp-sgx-io = { path = "../../../core-primitives/sgx/io", default-features = false } -lc-dynamic-assertion = { path = "../dynamic-assertion", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +itc-rest-client = { workspace = true } +itp-enclave-metrics = { workspace = true } +itp-ocall-api = { workspace = true } +itp-settings = { workspace = true } +itp-sgx-io = { workspace = true } +lc-dynamic-assertion = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -http_req = { features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } -lc-mock-server = { path = "../mock-server" } -litentry-primitives = { path = "../../primitives" } -litentry-hex-utils = { path = "../../../../../common/utils/hex" } +http_req = { workspace = true } +lc-mock-server = { workspace = true } +litentry-primitives = { workspace = true, features = ["std"] } +litentry-hex-utils = { workspace = true } [features] default = ["std"] @@ -63,7 +57,7 @@ sgx = [ "lc-dynamic-assertion/sgx", "itc-rest-client/sgx", "itp-sgx-io/sgx", - "thiserror-sgx", + "thiserror_sgx", "chrono_sgx", ] sgx-test = ["itp-sgx-temp-dir/sgx"] diff --git a/tee-worker/identity/litentry/core/identity-verification/Cargo.toml b/tee-worker/identity/litentry/core/identity-verification/Cargo.toml index aa4e117de4..25118dfbb7 100644 --- a/tee-worker/identity/litentry/core/identity-verification/Cargo.toml +++ b/tee-worker/identity/litentry/core/identity-verification/Cargo.toml @@ -5,41 +5,36 @@ name = "lc-identity-verification" version = "0.1.0" [dependencies] -# std dependencies -base64 = { version = "0.22", default-features = false, features = ["alloc"] } -hex = { version = "0.4.3", default-features = false } -http = { version = "0.2", optional = true } -http_req = { optional = true, features = ["rust-tls"], branch = "master", git = "https://github.com/integritee-network/http_req" } +base64 = { version = "0.22", default-features = false, features = ["alloc"] } # a newer base64 +hex = { workspace = true } +http = { workspace = true, optional = true } +http_req = { workspace = true, optional = true } lru = "0.12.3" rand = { version = "0.8", optional = true } -# sgx dependencies -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -http-sgx = { package = "http", git = "https://github.com/integritee-network/http-sgx.git", branch = "sgx-experimental", optional = true } -http_req-sgx = { package = "http_req", git = "https://github.com/integritee-network/http_req", default-features = false, features = ["rust-tls", "sgx"], optional = true } -sgx_rand = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +futures_sgx = { workspace = true, optional = true } +http-sgx = { workspace = true, optional = true } +http_req-sgx = { workspace = true, optional = true } +sgx_rand = { workspace = true, optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no_std dependencies -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } -log = { version = "0.4", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } +lazy_static = { workspace = true } +log = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } -# internal dependencies -itc-rest-client = { path = "../../../core/rest-client", default-features = false } -itp-sgx-crypto = { path = "../../../core-primitives/sgx/crypto", default-features = false } -itp-utils = { path = "../../../core-primitives/utils", default-features = false } +itc-rest-client = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-utils = { workspace = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +frame-support = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } -lc-data-providers = { path = "../data-providers", default-features = false } -lc-stf-task-sender = { path = "../stf-task/sender", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +lc-data-providers = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] @@ -53,7 +48,6 @@ sgx = [ "itp-sgx-crypto/sgx", "lc-data-providers/sgx", "litentry-primitives/sgx", - "lc-stf-task-sender/sgx", ] std = [ "http", @@ -66,6 +60,5 @@ std = [ "frame-support/std", "lc-data-providers/std", "litentry-primitives/std", - "lc-stf-task-sender/std", "rand", ] diff --git a/tee-worker/identity/litentry/core/identity-verification/src/lib.rs b/tee-worker/identity/litentry/core/identity-verification/src/lib.rs index 300b612dc8..763dd6b8aa 100644 --- a/tee-worker/identity/litentry/core/identity-verification/src/lib.rs +++ b/tee-worker/identity/litentry/core/identity-verification/src/lib.rs @@ -34,7 +34,7 @@ pub mod sgx_reexport_prelude { compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); use frame_support::pallet_prelude::*; -use lc_stf_task_sender::Web2IdentityVerificationRequest; +use litentry_primitives::Web2IdentityVerificationRequest; pub mod web2; diff --git a/tee-worker/identity/litentry/core/identity-verification/src/web2/mod.rs b/tee-worker/identity/litentry/core/identity-verification/src/web2/mod.rs index e3a9029b09..bac2c85022 100644 --- a/tee-worker/identity/litentry/core/identity-verification/src/web2/mod.rs +++ b/tee-worker/identity/litentry/core/identity-verification/src/web2/mod.rs @@ -17,16 +17,6 @@ #[cfg(all(not(feature = "std"), feature = "sgx"))] extern crate sgx_tstd as std; -// re-export module to properly feature gate sgx and regular std environment -#[cfg(all(not(feature = "std"), feature = "sgx"))] -pub mod sgx_reexport_prelude { - pub use http_req_sgx as http_req; - pub use http_sgx as http; -} - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -use crate::sgx_reexport_prelude::*; - #[cfg(all(feature = "std", feature = "sgx"))] compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); diff --git a/tee-worker/identity/litentry/core/mock-server/Cargo.toml b/tee-worker/identity/litentry/core/mock-server/Cargo.toml index 1656d921ee..db924e975e 100644 --- a/tee-worker/identity/litentry/core/mock-server/Cargo.toml +++ b/tee-worker/identity/litentry/core/mock-server/Cargo.toml @@ -4,17 +4,16 @@ name = "lc-mock-server" version = "0.1.0" [dependencies] -hex = "0.4.3" -log = "0.4" -serde_json = { version = "1.0", features = ["alloc"] } +hex = { workspace = true, features = ["std"] } +log = { workspace = true, features = ["std"] } +serde_json = { workspace = true, features = ["std"] } tokio = { version = "1.5", features = ["full"] } warp = "0.3" -# Substrate -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +sp-core = { workspace = true, features = ["std"] } # Internal dependencies -ita-stf = { path = "../../../app-libs/stf" } -itp-rpc = { path = "../../../core-primitives/rpc", default-features = false } -lc-data-providers = { path = "../data-providers" } -litentry-primitives = { path = "../../primitives" } +ita-stf = { package = "id-ita-stf", path = "../../../app-libs/stf" } +itp-rpc = { workspace = true, features = ["std"] } +lc-data-providers = { workspace = true, features = ["std"] } +litentry-primitives = { workspace = true, features = ["std"] } diff --git a/tee-worker/identity/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml deleted file mode 100644 index 51eeb07cae..0000000000 --- a/tee-worker/identity/litentry/core/parachain-extrinsic-task/receiver/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "lc-parachain-extrinsic-task-receiver" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -log = { version = "0.4", default-features = false } - -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } - -# internal dependencies -itp-extrinsics-factory = { path = "../../../../core-primitives/extrinsics-factory", default-features = false } -itp-ocall-api = { path = "../../../../core-primitives/ocall-api", default-features = false } -itp-types = { path = "../../../../core-primitives/types", default-features = false } -lc-parachain-extrinsic-task-sender = { path = "../sender", default-features = false } - -[features] -default = ["std"] -std = [ - "log/std", - "lc-parachain-extrinsic-task-sender/std", -] -sgx = [ - "sgx_tstd", - "lc-parachain-extrinsic-task-sender/sgx", -] diff --git a/tee-worker/identity/litentry/core/parachain-extrinsic-task/sender/Cargo.toml b/tee-worker/identity/litentry/core/parachain-extrinsic-task/sender/Cargo.toml deleted file mode 100644 index c7f7c958ad..0000000000 --- a/tee-worker/identity/litentry/core/parachain-extrinsic-task/sender/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "lc-parachain-extrinsic-task-sender" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -log = { version = "0.4", default-features = false } - -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["net", "thread"], optional = true } - -# no_std dependencies -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } - -# internal dependencies -itp-types = { path = "../../../../core-primitives/types", default-features = false } - -[features] -default = ["std"] -sgx = [ - "sgx_tstd", -] -std = [ - "log/std", -] diff --git a/tee-worker/identity/litentry/core/service/Cargo.toml b/tee-worker/identity/litentry/core/service/Cargo.toml index 52e3305649..ec063615e1 100644 --- a/tee-worker/identity/litentry/core/service/Cargo.toml +++ b/tee-worker/identity/litentry/core/service/Cargo.toml @@ -4,19 +4,13 @@ edition = "2021" name = "lc-service" version = "0.1.0" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["net", "thread"] } - -# no_std dependencies -log = { version = "0.4", default-features = false } +log = { workspace = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# litentry -lc-common = { path = "../common", default-features = false } -lc-data-providers = { path = "../data-providers", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } +lc-common = { workspace = true } +lc-data-providers = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/stf-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/stf-task/receiver/Cargo.toml index cbe16897e2..a74aeffcf5 100644 --- a/tee-worker/identity/litentry/core/stf-task/receiver/Cargo.toml +++ b/tee-worker/identity/litentry/core/stf-task/receiver/Cargo.toml @@ -5,58 +5,53 @@ name = "lc-stf-task-receiver" version = "0.1.0" [dependencies] -# std dependencies -futures = { version = "0.3.8", optional = true } -thiserror = { version = "1.0.26", optional = true } +futures = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true } -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +futures_sgx = { workspace = true, features = ["thread-pool"], optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +hex = { workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } -# internal dependencies -ita-stf = { path = "../../../../app-libs/stf", default-features = false } -itp-enclave-metrics = { path = "../../../../core-primitives/enclave-metrics", default-features = false } -itp-ocall-api = { path = "../../../../core-primitives/ocall-api", default-features = false } -itp-sgx-crypto = { path = "../../../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-externalities = { path = "../../../../core-primitives/substrate-sgx/externalities", default-features = false } -itp-stf-executor = { path = "../../../../core-primitives/stf-executor", 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 } -itp-top-pool-author = { path = "../../../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../../../core-primitives/types", default-features = false } -itp-utils = { path = "../../../../core-primitives/utils", default-features = false } +ita-stf = { package = "id-ita-stf", path = "../../../../app-libs/stf", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../../core-primitives/stf-executor", default-features = false } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } +itp-utils = { workspace = true } -# litentry -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -ita-sgx-runtime = { path = "../../../../app-libs/sgx-runtime", default-features = false } -lc-assertion-build = { path = "../../assertion-build", default-features = false } -lc-assertion-build-v2 = { path = "../../assertion-build-v2", default-features = false } -lc-credentials = { path = "../../credentials", default-features = false } -lc-data-providers = { path = "../../data-providers", default-features = false } -lc-dynamic-assertion = { path = "../../dynamic-assertion", default-features = false } -lc-evm-dynamic-assertions = { path = "../../evm-dynamic-assertions", default-features = false } -lc-identity-verification = { path = "../../identity-verification", default-features = false } -lc-stf-task-sender = { path = "../sender", default-features = false } -litentry-primitives = { path = "../../../primitives", default-features = false } +frame-support = { workspace = true } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../../../../app-libs/sgx-runtime", default-features = false } +lc-assertion-build = { workspace = true } +lc-assertion-build-v2 = { workspace = true } +lc-credentials = { workspace = true } +lc-data-providers = { workspace = true } +lc-dynamic-assertion = { workspace = true } +lc-evm-dynamic-assertions = { workspace = true } +lc-identity-verification = { workspace = true } +lc-stf-task-sender = { workspace = true } +litentry-primitives = { workspace = true } [dev-dependencies] -sgx_crypto_helper = { version = "1.1.6", git = "https://github.com/apache/incubator-teaclave-sgx-sdk", branch = "master" } -itp-test = { path = "../../../../core-primitives/test" } -itp-top-pool-author = { path = "../../../../core-primitives/top-pool-author", features = ["mocks"] } -itp-top-pool = { path = "../../../../core-primitives/top-pool", features = ["mocks"] } -itp-stf-executor = { path = "../../../../core-primitives/stf-executor", features = ["mocks"] } -itp-sgx-crypto = { path = "../../../../core-primitives/sgx/crypto", features = ["mocks"] } -base58 = "0.2" +sgx_crypto_helper = { workspace = true } +itp-test = { workspace = true, features = ["std"] } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../../../core-primitives/top-pool-author", features = ["mocks"] } +itp-top-pool = { package = "id-itp-top-pool", path = "../../../../core-primitives/top-pool", features = ["mocks"] } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../../core-primitives/stf-executor", features = ["mocks"] } +itp-sgx-crypto = { workspace = true, features = ["std"] } +base58 = { workspace = true } jsonrpc-core = { version = "18" } lazy_static = { version = "1.1.0" } -hex = "0.4.2" +hex = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/assertion.rs b/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/assertion.rs index d8db0a464d..b69c074bc1 100644 --- a/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/assertion.rs +++ b/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/assertion.rs @@ -28,10 +28,9 @@ use lc_credentials::credential_schema; use lc_data_providers::DataProviderConfig; use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::AssertionRepositoryItem; -use lc_stf_task_sender::AssertionBuildRequest; use litentry_primitives::{ - AmountHoldingTimeType, Assertion, ErrorDetail, ErrorString, Identity, ParameterString, - VCMPError, + AmountHoldingTimeType, Assertion, AssertionBuildRequest, ErrorDetail, ErrorString, Identity, + ParameterString, VCMPError, }; use log::*; use sp_core::{Pair, H160}; diff --git a/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/identity_verification.rs b/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/identity_verification.rs index d0d47784aa..535d608120 100644 --- a/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/identity_verification.rs +++ b/tee-worker/identity/litentry/core/stf-task/receiver/src/handler/identity_verification.rs @@ -27,8 +27,7 @@ use itp_top_pool_author::traits::AuthorApi; use itp_types::{ShardIdentifier, H256}; use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::AssertionRepositoryItem; -use lc_stf_task_sender::Web2IdentityVerificationRequest; -use litentry_primitives::IMPError; +use litentry_primitives::{IMPError, Web2IdentityVerificationRequest}; use log::*; use sp_core::H160; use std::sync::{mpsc::Sender, Arc}; diff --git a/tee-worker/identity/litentry/core/stf-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/stf-task/receiver/src/lib.rs index 27c1fca321..87301516f0 100644 --- a/tee-worker/identity/litentry/core/stf-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/stf-task/receiver/src/lib.rs @@ -52,7 +52,8 @@ use itp_types::{RsaRequest, ShardIdentifier, H256}; use lc_data_providers::DataProviderConfig; use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::AssertionRepositoryItem; -use lc_stf_task_sender::{init_stf_task_sender_storage, RequestType}; +use lc_stf_task_sender::init_stf_task_sender_storage; +use litentry_primitives::RequestType; use log::*; use sp_core::{ed25519::Pair as Ed25519Pair, H160}; use std::{ diff --git a/tee-worker/identity/litentry/core/stf-task/sender/Cargo.toml b/tee-worker/identity/litentry/core/stf-task/sender/Cargo.toml index 411b0f5cb5..3b34e4f2ca 100644 --- a/tee-worker/identity/litentry/core/stf-task/sender/Cargo.toml +++ b/tee-worker/identity/litentry/core/stf-task/sender/Cargo.toml @@ -5,27 +5,20 @@ name = "lc-stf-task-sender" version = "0.1.0" [dependencies] -# std dependencies -thiserror = { version = "1.0.26", optional = true } +thiserror = { workspace = true, optional = true } -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["net", "thread"], optional = true } -thiserror_sgx = { package = "thiserror", git = "https://github.com/mesalock-linux/thiserror-sgx", tag = "sgx_1.1.3", optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } +thiserror_sgx = { workspace = true, optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } -log = { version = "0.4", default-features = false } +codec = { package = "parity-scale-codec", workspace = true } +lazy_static = { workspace = true } +log = { workspace = true } -# substrate dependencies -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } +sp-runtime = { workspace = true } +sp-std = { workspace = true } -# internal dependencies -itp-types = { path = "../../../../core-primitives/types", default-features = false } - -# litentry -litentry-primitives = { path = "../../../primitives", default-features = false } +itp-types = { workspace = true } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/stf-task/sender/src/lib.rs b/tee-worker/identity/litentry/core/stf-task/sender/src/lib.rs index e051b9061e..0079eba92d 100644 --- a/tee-worker/identity/litentry/core/stf-task/sender/src/lib.rs +++ b/tee-worker/identity/litentry/core/stf-task/sender/src/lib.rs @@ -35,8 +35,7 @@ use log::*; mod error; pub use error::*; -mod request; -pub use request::*; +use litentry_primitives::RequestType; #[cfg(feature = "std")] use std::sync::Mutex; diff --git a/tee-worker/identity/litentry/core/teebag-storage/Cargo.toml b/tee-worker/identity/litentry/core/teebag-storage/Cargo.toml deleted file mode 100644 index c68b9e0d5e..0000000000 --- a/tee-worker/identity/litentry/core/teebag-storage/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "lc-teebag-storage" -version = "0.1.0" -authors = ['Trust Computing GmbH '] -edition = "2021" - -[dependencies] -itp-storage = { path = "../../../core-primitives/storage", default-features = false } -itp-types = { path = "../../../core-primitives/types", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", default-features = false } - -[features] -default = ["std"] -std = [ - "sp-std/std", - "itp-storage/std", - "itp-types/std", -] diff --git a/tee-worker/identity/litentry/core/teebag-storage/src/lib.rs b/tee-worker/identity/litentry/core/teebag-storage/src/lib.rs deleted file mode 100644 index 3f931d9f7e..0000000000 --- a/tee-worker/identity/litentry/core/teebag-storage/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020-2024 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 . - -#![cfg_attr(not(feature = "std"), no_std)] - -use itp_storage::{storage_map_key, StorageHasher}; -use itp_types::WorkerType; -use sp_std::prelude::Vec; - -pub struct TeebagStorage; - -pub trait StoragePrefix { - fn prefix() -> &'static str; -} - -impl StoragePrefix for TeebagStorage { - fn prefix() -> &'static str { - "Teebag" - } -} - -pub trait TeebagStorageKeys { - fn enclave_identifier(worker_type: WorkerType) -> Vec; -} - -impl TeebagStorageKeys for S { - fn enclave_identifier(worker_type: WorkerType) -> Vec { - storage_map_key( - Self::prefix(), - "EnclaveIdentifier", - &worker_type, - &StorageHasher::Blake2_128Concat, - ) - } -} diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml index eed2ef1760..e581fb153c 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml +++ b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml @@ -3,46 +3,39 @@ name = "lc-vc-task-receiver" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# std dependencies -futures = { version = "0.3.8", optional = true } - -# sgx dependencies -futures_sgx = { package = "futures", git = "https://github.com/mesalock-linux/futures-rs-sgx", optional = true, features = ["thread-pool"] } -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", features = ["net", "thread"], optional = true } +futures = { workspace = true, optional = true } +futures_sgx = { workspace = true, features = ["thread-pool"], optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no_std dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4", default-features = false } -sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true } +log = { workspace = true } +sp-core = { workspace = true, features = ["full_crypto"] } -# internal dependencies -ita-sgx-runtime = { path = "../../../../app-libs/sgx-runtime", default-features = false } -ita-stf = { path = "../../../../app-libs/stf", default-features = false } -itp-enclave-metrics = { path = "../../../../core-primitives/enclave-metrics", default-features = false } -itp-node-api = { path = "../../../../core-primitives/node-api", default-features = false } -itp-ocall-api = { path = "../../../../core-primitives/ocall-api", default-features = false } -itp-sgx-crypto = { path = "../../../../core-primitives/sgx/crypto", default-features = false } -itp-sgx-externalities = { path = "../../../../core-primitives/substrate-sgx/externalities", default-features = false } -itp-stf-executor = { path = "../../../../core-primitives/stf-executor", 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 } -itp-storage = { path = "../../../../core-primitives/storage", default-features = false } -itp-top-pool-author = { path = "../../../../core-primitives/top-pool-author", default-features = false } -itp-types = { path = "../../../../core-primitives/types", default-features = false } +ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../../../../app-libs/sgx-runtime", default-features = false } +ita-stf = { package = "id-ita-stf", path = "../../../../app-libs/stf", default-features = false } +itp-enclave-metrics = { workspace = true } +itp-node-api = { workspace = true } +itp-ocall-api = { workspace = true } +itp-sgx-crypto = { workspace = true } +itp-sgx-externalities = { workspace = true } +itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../../core-primitives/stf-executor", default-features = false } +itp-stf-primitives = { workspace = true } +itp-stf-state-handler = { workspace = true } +itp-storage = { workspace = true } +itp-top-pool-author = { package = "id-itp-top-pool-author", path = "../../../../core-primitives/top-pool-author", default-features = false } +itp-types = { workspace = true } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -lc-dynamic-assertion = { path = "../../dynamic-assertion", default-features = false } -lc-evm-dynamic-assertions = { path = "../../evm-dynamic-assertions", default-features = false } -lc-parachain-extrinsic-task-sender = { path = "../../parachain-extrinsic-task/sender", default-features = false } -lc-stf-task-receiver = { path = "../../stf-task/receiver", default-features = false } -lc-stf-task-sender = { path = "../../stf-task/sender", default-features = false } -lc-vc-task-sender = { path = "../sender", default-features = false } -litentry-macros = { path = "../../../../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../../../primitives", default-features = false } -pallet-identity-management-tee = { path = "../../../pallets/identity-management", default-features = false } +frame-support = { workspace = true } +lc-dynamic-assertion = { workspace = true } +lc-evm-dynamic-assertions = { workspace = true } +lc-parachain-extrinsic-task-sender = { workspace = true } +lc-stf-task-receiver = { workspace = true } +lc-stf-task-sender = { workspace = true } +lc-vc-task-sender = { workspace = true } +litentry-macros = { workspace = true } +litentry-primitives = { workspace = true } +pallet-identity-management-tee = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs index ae49836466..727258f173 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs @@ -24,7 +24,8 @@ use codec::{Decode, Encode}; use frame_support::{ensure, sp_runtime::traits::One}; use futures::executor::ThreadPoolBuilder; use ita_sgx_runtime::{ - pallet_imt::get_eligible_identities, BlockNumber, Hash, Runtime, VERSION as SIDECHAIN_VERSION, + pallet_identity_management_tee::get_eligible_identities, BlockNumber, Hash, Runtime, + VERSION as SIDECHAIN_VERSION, }; #[cfg(feature = "development")] @@ -55,10 +56,11 @@ use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::AssertionRepositoryItem; use lc_parachain_extrinsic_task_sender::{ParachainExtrinsicSender, SendParachainExtrinsic}; use lc_stf_task_receiver::{handler::assertion::create_credential_str, StfTaskContext}; -use lc_stf_task_sender::AssertionBuildRequest; use lc_vc_task_sender::init_vc_task_sender; use litentry_macros::if_development_or; -use litentry_primitives::{Assertion, DecryptableRequest, Identity, ParentchainBlockNumber}; +use litentry_primitives::{ + Assertion, AssertionBuildRequest, DecryptableRequest, Identity, ParentchainBlockNumber, +}; use log::*; use pallet_identity_management_tee::{identity_context::sort_id_graph, IdentityContext}; use sp_core::{blake2_256, H160}; diff --git a/tee-worker/identity/litentry/core/vc-task/sender/Cargo.toml b/tee-worker/identity/litentry/core/vc-task/sender/Cargo.toml index 93d38ee901..71720516c9 100644 --- a/tee-worker/identity/litentry/core/vc-task/sender/Cargo.toml +++ b/tee-worker/identity/litentry/core/vc-task/sender/Cargo.toml @@ -3,18 +3,13 @@ name = "lc-vc-task-sender" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -# sgx dependencies -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", features = ["net", "thread"], optional = true } +sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } -# no_std dependencies -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } -log = { version = "0.4", default-features = false } +lazy_static = { workspace = true } +log = { workspace = true } -# litentry -litentry-primitives = { path = "../../../primitives", default-features = false } +litentry-primitives = { workspace = true } [features] default = ["std"] diff --git a/tee-worker/identity/litentry/pallets/identity-management/Cargo.toml b/tee-worker/identity/litentry/pallets/identity-management/Cargo.toml deleted file mode 100644 index a7b5049bae..0000000000 --- a/tee-worker/identity/litentry/pallets/identity-management/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -authors = ['Trust Computing GmbH ', 'Integritee AG '] -edition = '2021' -homepage = 'https://litentry.com' -name = 'pallet-identity-management-tee' -repository = 'https://github.com/litentry/litentry-parachain' -version = '0.1.0' - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } -hex = { version = "0.4", default-features = false } -log = { version = "0.4", default-features = false } -scale-info = { version = "2.4.0", default-features = false, features = ["derive"] } - -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -litentry-primitives = { path = "../../primitives", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } - -[dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } - -[features] -default = ["std"] - -std = [ - "codec/std", - "sp-std/std", - "sp-runtime/std", - "sp-io/std", - "sp-core/std", - "frame-support/std", - "frame-system/std", - "log/std", - "pallet-balances/std", - "litentry-primitives/std", -] - -development = [] diff --git a/tee-worker/identity/litentry/primitives/Cargo.toml b/tee-worker/identity/litentry/primitives/Cargo.toml deleted file mode 100644 index 9f3a4e6cfa..0000000000 --- a/tee-worker/identity/litentry/primitives/Cargo.toml +++ /dev/null @@ -1,59 +0,0 @@ -[package] -authors = ["Trust Computing GmbH "] -edition = "2021" -name = "litentry-primitives" -version = "0.1.0" - -[dependencies] -bitcoin = { version = "0.31.0", default-features = false, features = ["secp-recovery", "no-std"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -hex = { version = "0.4.3", default-features = false } -log = { version = "0.4", default-features = false } -rand = { version = "0.7", optional = true } -rand-sgx = { package = "rand", git = "https://github.com/mesalock-linux/rand-sgx", tag = "sgx_1.1.3", features = ["sgx_tstd"], optional = true } -ring = { version = "0.16.20", default-features = false } -scale-info = { version = "2.4.0", default-features = false, features = ["derive"] } -secp256k1 = { version = "0.28.0", default-features = false } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } - -# sgx dependencies -sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "master", optional = true, features = ["net", "thread"] } - -# internal dependencies -itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false } -pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } -parentchain-primitives = { package = "core-primitives", git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } - -[dev-dependencies] -base64 = { version = "0.13", features = ["alloc"] } - -[features] -default = ["std"] -development = [ - "parentchain-primitives/development", -] -sgx = [ - "sgx_tstd", - "rand-sgx", - "itp-sgx-crypto/sgx", -] -std = [ - "hex/std", - "serde/std", - "itp-sgx-crypto/std", - "sp-core/std", - "sp-std/std", - "sp-io/std", - "sp-runtime/std", - "ring/std", - "parentchain-primitives/std", - "pallet-teebag/std", - "rand", - "log/std", - "bitcoin/std", - "secp256k1/std", -] diff --git a/tee-worker/identity/litentry/primitives/src/aes.rs b/tee-worker/identity/litentry/primitives/src/aes.rs deleted file mode 100644 index 8abbb7b149..0000000000 --- a/tee-worker/identity/litentry/primitives/src/aes.rs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2020-2024 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 . - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate sgx_tstd as std; - -#[cfg(all(not(feature = "std"), feature = "sgx"))] -extern crate rand_sgx as rand; - -use crate::{Decode, Encode, Vec}; - -use rand::Rng; - -use ring::{ - aead::{Aad, BoundKey, LessSafeKey, Nonce, NonceSequence, SealingKey, UnboundKey, AES_256_GCM}, - error::Unspecified, -}; - -// we use 256-bit AES-GCM as request enc/dec key -pub const REQUEST_AES_KEY_LEN: usize = 32; -pub use ring::aead::{MAX_TAG_LEN, NONCE_LEN}; - -pub type RequestAesKey = [u8; REQUEST_AES_KEY_LEN]; -pub type RequestAesKeyNonce = [u8; NONCE_LEN]; - -// all-in-one struct containing the encrypted ciphertext with other -// metadata that is required for decryption -// -// by default a postfix tag is used => last 16 bytes of ciphertext is MAC tag -#[derive(Debug, Default, Clone, Eq, PartialEq, Encode, Decode)] -pub struct AesOutput { - pub ciphertext: Vec, - pub aad: Vec, - pub nonce: RequestAesKeyNonce, // IV -} - -// Returns the default if any error happens -// We don't propagate the error to upper level as this function is used in too many places, -// it's too verbose to handle them all and pass back to the parentchain as events. -// We rely on the parentchain event consumers to handle them correctly (and they kind of -// have to, because they'll find all fields are 0) -pub fn aes_encrypt_default(key: &RequestAesKey, data: &[u8]) -> AesOutput { - let mut in_out = data.to_vec(); - - let mut nonce = RingAeadNonceSequence::new(); - if nonce.advance().is_ok() { - let aad = b""; - if let Ok(unbound_key) = UnboundKey::new(&AES_256_GCM, key.as_slice()) { - let mut sealing_key = SealingKey::new(unbound_key, nonce.clone()); - if sealing_key.seal_in_place_append_tag(Aad::from(aad), &mut in_out).is_ok() { - return AesOutput { - ciphertext: in_out.to_vec(), - aad: aad.to_vec(), - nonce: nonce.nonce, - } - } - } - } - - AesOutput::default() -} - -// use LessSafeKey::seal_in_place_append_tag to encrypt the data using the given nonce -// don't be scared by the name, it's similar to `SealingKey::seal_in_place_append_tag`, -// except that it accepts an arbitrary nonce. -// It's only used by the one-off verification message calculation. -pub fn aes_encrypt_nonce(key: &RequestAesKey, data: &[u8], nonce: RequestAesKeyNonce) -> AesOutput { - let mut in_out = data.to_vec(); - let aad = b""; - if let Ok(unbound_key) = UnboundKey::new(&AES_256_GCM, key.as_slice()) { - let less_safe_key = LessSafeKey::new(unbound_key); - if less_safe_key - .seal_in_place_append_tag( - Nonce::assume_unique_for_key(nonce), - Aad::from(aad), - &mut in_out, - ) - .is_ok() - { - return AesOutput { ciphertext: in_out.to_vec(), aad: aad.to_vec(), nonce } - } - } - - AesOutput::default() -} - -pub fn aes_decrypt(key: &RequestAesKey, data: &mut AesOutput) -> Option> { - let in_out = data.ciphertext.as_mut(); - if let Ok(unbound_key) = UnboundKey::new(&AES_256_GCM, key.as_slice()) { - let less_safe_key = LessSafeKey::new(unbound_key); - return less_safe_key - .open_in_place( - Nonce::assume_unique_for_key(data.nonce), - Aad::from(data.aad.clone()), - in_out, - ) - .ok() - .map(|data| data.to_vec()) - } - None -} - -#[derive(Clone)] -pub struct RingAeadNonceSequence { - pub nonce: RequestAesKeyNonce, -} - -impl RingAeadNonceSequence { - fn new() -> RingAeadNonceSequence { - RingAeadNonceSequence { nonce: [0u8; NONCE_LEN] } - } -} - -impl NonceSequence for RingAeadNonceSequence { - fn advance(&mut self) -> Result { - let nonce = Nonce::assume_unique_for_key(self.nonce); - let nonce_vec = rand::thread_rng().gen::(); - self.nonce.copy_from_slice(&nonce_vec[0..NONCE_LEN]); - Ok(nonce) - } -} diff --git a/tee-worker/identity/litentry/primitives/src/bitcoin_signature.rs b/tee-worker/identity/litentry/primitives/src/bitcoin_signature.rs deleted file mode 100644 index 689e088fbc..0000000000 --- a/tee-worker/identity/litentry/primitives/src/bitcoin_signature.rs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2020-2024 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 . -#[cfg(feature = "std")] -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; - -use codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; - -#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Eq, Clone, Debug)] -pub struct BitcoinSignature(pub [u8; 65]); - -impl TryFrom<&[u8]> for BitcoinSignature { - type Error = (); - - fn try_from(data: &[u8]) -> Result { - if data.len() == 65 { - let mut inner = [0u8; 65]; - inner.copy_from_slice(data); - Ok(BitcoinSignature(inner)) - } else { - Err(()) - } - } -} - -#[cfg(feature = "std")] -impl Serialize for BitcoinSignature { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(&hex::encode(self)) - } -} - -#[cfg(feature = "std")] -impl<'de> Deserialize<'de> for BitcoinSignature { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let signature_hex = hex::decode(&String::deserialize(deserializer)?) - .map_err(|e| de::Error::custom(format!("{:?}", e)))?; - BitcoinSignature::try_from(signature_hex.as_ref()) - .map_err(|e| de::Error::custom(format!("{:?}", e))) - } -} - -impl AsRef<[u8; 65]> for BitcoinSignature { - fn as_ref(&self) -> &[u8; 65] { - &self.0 - } -} - -impl AsRef<[u8]> for BitcoinSignature { - fn as_ref(&self) -> &[u8] { - &self.0[..] - } -} diff --git a/tee-worker/identity/litentry/primitives/src/ethereum_signature.rs b/tee-worker/identity/litentry/primitives/src/ethereum_signature.rs deleted file mode 100644 index e0869efd08..0000000000 --- a/tee-worker/identity/litentry/primitives/src/ethereum_signature.rs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2020-2024 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 . -#[cfg(feature = "std")] -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; - -use codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; - -#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Eq, Clone, Debug)] -pub struct EthereumSignature(pub [u8; 65]); - -impl TryFrom<&[u8]> for EthereumSignature { - type Error = (); - - fn try_from(data: &[u8]) -> Result { - if data.len() == 65 { - let mut inner = [0u8; 65]; - inner.copy_from_slice(data); - Ok(EthereumSignature(inner)) - } else { - Err(()) - } - } -} - -#[cfg(feature = "std")] -impl Serialize for EthereumSignature { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(&hex::encode(self)) - } -} - -#[cfg(feature = "std")] -impl<'de> Deserialize<'de> for EthereumSignature { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let signature_hex = hex::decode(&String::deserialize(deserializer)?) - .map_err(|e| de::Error::custom(format!("{:?}", e)))?; - EthereumSignature::try_from(signature_hex.as_ref()) - .map_err(|e| de::Error::custom(format!("{:?}", e))) - } -} - -impl AsRef<[u8; 65]> for EthereumSignature { - fn as_ref(&self) -> &[u8; 65] { - &self.0 - } -} - -impl AsRef<[u8]> for EthereumSignature { - fn as_ref(&self) -> &[u8] { - &self.0[..] - } -} diff --git a/tee-worker/identity/rust-toolchain.toml b/tee-worker/identity/rust-toolchain.toml deleted file mode 100644 index 23ed88e6c8..0000000000 --- a/tee-worker/identity/rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2022-10-22" -targets = ["wasm32-unknown-unknown"] -profile = "default" # include rustfmt, clippy diff --git a/tee-worker/identity/rustfmt.toml b/tee-worker/identity/rustfmt.toml deleted file mode 100644 index 104b9aa998..0000000000 --- a/tee-worker/identity/rustfmt.toml +++ /dev/null @@ -1,18 +0,0 @@ -# Basic -hard_tabs = true -max_width = 100 -use_small_heuristics = "Max" -# Imports -imports_granularity = "Crate" -reorder_imports = true -# Consistency -newline_style = "Unix" -# Misc -chain_width = 80 -spaces_around_ranges = false -match_arm_leading_pipes = "Preserve" -match_arm_blocks = false -match_block_trailing_comma = true -trailing_comma = "Vertical" -trailing_semicolon = false -use_field_init_shorthand = true \ No newline at end of file diff --git a/tee-worker/identity/service/Cargo.toml b/tee-worker/identity/service/Cargo.toml index 6bbf0edcee..f444c35fe4 100644 --- a/tee-worker/identity/service/Cargo.toml +++ b/tee-worker/identity/service/Cargo.toml @@ -22,63 +22,58 @@ parse_duration = "2.1.1" prometheus = { version = "0.13.0", features = ["process"], default-features = false } # Enabling std lead to protobuf dependency conflicts with substrate, and we don't need it. rayon = "1.10.0" regex = "1.9.5" -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" -thiserror = "1.0" +scale-info = { workspace = true, features = ["std"] } +serde = { workspace = true, features = ["std"] } +serde_derive = { workspace = true } +serde_json = { workspace = true, features = ["std"] } +thiserror = { workspace = true } tokio = { version = "1.6.1", features = ["full"] } url = "2.5.0" warp = "0.3" -# ipfs ipfs-api = "0.11.0" -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -primitive-types = { version = "0.12.1", default-features = false, features = ["codec"] } +codec = { package = "parity-scale-codec", workspace = true } +primitive-types = { workspace = true, features = ["codec"] } -sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } -sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" } +sgx_crypto_helper = { workspace = true, features = ["ucrypto_help"] } +sgx_types = { workspace = true } -# local -ita-parentchain-interface = { path = "../app-libs/parentchain-interface" } -itc-parentchain = { path = "../core/parentchain/parentchain-crate" } -itc-rest-client = { path = "../core/rest-client" } -itc-rpc-client = { path = "../core/rpc-client" } -itc-rpc-server = { path = "../core/rpc-server" } -itp-api-client-types = { path = "../core-primitives/node-api/api-client-types" } -itp-enclave-api = { path = "../core-primitives/enclave-api" } -itp-enclave-metrics = { path = "../core-primitives/enclave-metrics" } -itp-node-api = { path = "../core-primitives/node-api" } -itp-settings = { path = "../core-primitives/settings" } -itp-stf-interface = { path = "../core-primitives/stf-interface" } -itp-storage = { path = "../core-primitives/storage" } -itp-time-utils = { path = "../core-primitives/time-utils" } -itp-types = { path = "../core-primitives/types" } -itp-utils = { path = "../core-primitives/utils" } -its-consensus-slots = { path = "../sidechain/consensus/slots" } -its-peer-fetch = { path = "../sidechain/peer-fetch" } -its-primitives = { path = "../sidechain/primitives" } -its-rpc-handler = { path = "../sidechain/rpc-handler" } -its-storage = { path = "../sidechain/storage" } +ita-parentchain-interface = { package = "id-ita-parentchain-interface", path = "../app-libs/parentchain-interface" } -# `default-features = false` to remove the jsonrpsee dependency. -substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } +itc-rest-client = { workspace = true, features = ["std"] } +itc-rpc-client = { workspace = true } +itc-rpc-server = { workspace = true, features = ["std"] } +itp-api-client-types = { workspace = true, features = ["std"] } +itp-enclave-api = { package = "id-itp-enclave-api", path = "../core-primitives/enclave-api" } +itp-enclave-metrics = { workspace = true, features = ["std"] } +itp-node-api = { workspace = true, features = ["std"] } +itp-settings = { workspace = true } +itp-stf-interface = { workspace = true, features = ["std"] } +itp-storage = { workspace = true, features = ["std"] } +itp-time-utils = { workspace = true, features = ["std"] } +itp-types = { workspace = true, features = ["std"] } +itp-utils = { workspace = true, features = ["std"] } -# Substrate dependencies -frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42", features = ["full_crypto"] } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +its-consensus-slots = { workspace = true, features = ["std"] } +its-peer-fetch = { workspace = true, features = ["std"] } +its-primitives = { workspace = true, features = ["std"] } +its-rpc-handler = { workspace = true, features = ["std"] } +its-storage = { workspace = true } + +substrate-api-client = { workspace = true } + +frame-support = { workspace = true, features = ["std"] } +sp-consensus-grandpa = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } +sp-keyring = { workspace = true } +sp-runtime = { workspace = true, features = ["std"] } -# litentry config = "0.13.3" -lc-data-providers = { path = "../litentry/core/data-providers" } -lc-mock-server = { path = "../litentry/core/mock-server" } -lc-stf-task-sender = { path = "../litentry/core/stf-task/sender", default-features = false } -litentry-macros = { path = "../../../common/primitives/core/macros", default-features = false } -litentry-primitives = { path = "../litentry/primitives" } +lc-data-providers = { workspace = true, features = ["std"] } +lc-mock-server = { workspace = true } +litentry-macros = { workspace = true } +litentry-primitives = { workspace = true, features = ["std"] } [features] default = [] @@ -107,10 +102,8 @@ link-binary = [ mock-server = [] [dev-dependencies] -# crates.io anyhow = "1.0.40" mockall = "0.11" -# local -itc-parentchain-test = { path = "../core/parentchain/test" } -its-peer-fetch = { path = "../sidechain/peer-fetch", features = ["mocks"] } -its-test = { path = "../sidechain/test" } +itc-parentchain-test = { workspace = true } +its-peer-fetch = { workspace = true, features = ["std", "mocks"] } +its-test = { workspace = true, features = ["std"] } diff --git a/tee-worker/identity/service/src/main_impl.rs b/tee-worker/identity/service/src/main_impl.rs index a76726a2cb..137e0e90f8 100644 --- a/tee-worker/identity/service/src/main_impl.rs +++ b/tee-worker/identity/service/src/main_impl.rs @@ -63,8 +63,7 @@ use substrate_api_client::{ use litentry_primitives::extract_tcb_info_from_raw_dcap_quote; use crate::error::ServiceResult; -use itc_parentchain::primitives::ParentchainId; -use itp_types::parentchain::{AccountId, Balance}; +use itp_types::parentchain::{AccountId, Balance, ParentchainId}; use sp_core::crypto::{AccountId32, Ss58Codec}; use sp_keyring::AccountKeyring; use sp_runtime::MultiSigner; diff --git a/tee-worker/identity/service/src/parentchain_handler.rs b/tee-worker/identity/service/src/parentchain_handler.rs index 6aa9f7069a..ca33f38bab 100644 --- a/tee-worker/identity/service/src/parentchain_handler.rs +++ b/tee-worker/identity/service/src/parentchain_handler.rs @@ -20,16 +20,15 @@ use crate::error::{Error, ServiceResult}; use codec::{Decode, Encode}; use humantime::format_duration; use ita_parentchain_interface::integritee::Header; -use itc_parentchain::{ - light_client::light_client_init_params::{GrandpaParams, SimpleParams}, - primitives::{ParentchainId, ParentchainInitParams}, -}; use itp_api_client_types::ParentchainApi; use itp_enclave_api::{enclave_base::EnclaveBase, sidechain::Sidechain}; use itp_node_api::api_client::ChainApi; use itp_storage::StorageProof; use itp_time_utils::duration_now; -use itp_types::ShardIdentifier; +use itp_types::{ + parentchain::{GrandpaParams, ParentchainId, ParentchainInitParams, SimpleParams}, + ShardIdentifier, +}; use log::*; use rayon::prelude::*; use sp_consensus_grandpa::VersionedAuthorityList; diff --git a/tee-worker/identity/service/src/prometheus_metrics.rs b/tee-worker/identity/service/src/prometheus_metrics.rs index ff03df163b..e23f2ecdc0 100644 --- a/tee-worker/identity/service/src/prometheus_metrics.rs +++ b/tee-worker/identity/service/src/prometheus_metrics.rs @@ -34,8 +34,7 @@ use itc_rest_client::{ }; use itp_enclave_metrics::EnclaveMetric; use lazy_static::lazy_static; -use lc_stf_task_sender::RequestType; -use litentry_primitives::{Assertion, Identity}; +use litentry_primitives::{Assertion, Identity, RequestType}; use log::*; use prometheus::{ proto::MetricFamily, register_counter, register_counter_vec, register_histogram, @@ -261,6 +260,7 @@ impl ReceiveEnclaveMetrics for EnclaveMetricsReceiver { EnclaveMetric::DynamicAssertionGetTime(time) => { DYNAMIC_ASSERTION_GET_TIME.observe(time.as_secs_f64()); }, + _ => warn!("Not supported metric: {:?}", metric), } Ok(()) } diff --git a/tee-worker/identity/service/src/tests/mocks/enclave_api_mock.rs b/tee-worker/identity/service/src/tests/mocks/enclave_api_mock.rs index 55e098c36b..fc194e4f63 100644 --- a/tee-worker/identity/service/src/tests/mocks/enclave_api_mock.rs +++ b/tee-worker/identity/service/src/tests/mocks/enclave_api_mock.rs @@ -17,16 +17,15 @@ use codec::{Decode, Encode}; use core::fmt::Debug; -use itc_parentchain::primitives::{ - ParentchainId, ParentchainInitParams, - ParentchainInitParams::{Parachain, Solochain}, -}; use itp_enclave_api::{enclave_base::EnclaveBase, sidechain::Sidechain, EnclaveResult}; use itp_settings::worker::MR_ENCLAVE_SIZE; use itp_stf_interface::ShardCreationInfo; use itp_storage::StorageProof; use itp_types::{ - parentchain::{Balance, Header}, + parentchain::{ + Balance, Header, ParentchainId, ParentchainInitParams, + ParentchainInitParams::{Parachain, Solochain}, + }, EnclaveFingerprint, ShardIdentifier, }; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; diff --git a/tee-worker/identity/service/src/tests/parentchain_handler_test.rs b/tee-worker/identity/service/src/tests/parentchain_handler_test.rs index 30339e92bb..90c5ea575f 100644 --- a/tee-worker/identity/service/src/tests/parentchain_handler_test.rs +++ b/tee-worker/identity/service/src/tests/parentchain_handler_test.rs @@ -19,10 +19,7 @@ use crate::{ parentchain_handler::{HandleParentchain, ParentchainHandler}, tests::mocks::{enclave_api_mock::EnclaveMock, parentchain_api_mock::ParentchainApiMock}, }; -use itc_parentchain::{ - light_client::light_client_init_params::SimpleParams, - primitives::{ParentchainId, ParentchainInitParams}, -}; +use itp_types::parentchain::{ParentchainId, ParentchainInitParams, SimpleParams}; use itc_parentchain_test::ParentchainHeaderBuilder; use itp_node_api::api_client::ChainApi; use std::sync::Arc; diff --git a/tee-worker/identity/sidechain/block-composer/Cargo.toml b/tee-worker/identity/sidechain/block-composer/Cargo.toml index 0bae2c3ee1..1b57a282d0 100644 --- a/tee-worker/identity/sidechain/block-composer/Cargo.toml +++ b/tee-worker/identity/sidechain/block-composer/Cargo.toml @@ -5,35 +5,29 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG ', 'Integritee AG ', 'Integritee AG '] edition = "2021" - [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -derive_more = "0.99.16" -lazy_static = { version = "1.1.0", features = ["spin_no_std"] } -log = { version = "0.4", default-features = false } - -# local deps -itp-types = { path = "../../../core-primitives/types", default-features = false } -its-block-verification = { path = "../../block-verification", default-features = false } -its-primitives = { path = "../../primitives", default-features = false } - -# only for slot-stream +codec = { package = "parity-scale-codec", workspace = true } +derive_more = { workspace = true } futures-timer = { version = "3.0", optional = true } +lazy_static = { workspace = true } +log = { workspace = true } -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true, features = ["untrusted_time"] } +itp-settings = { workspace = true } +itp-time-utils = { workspace = true } +itp-types = { workspace = true } +its-block-verification = { workspace = true } +its-consensus-common = { workspace = true } +its-primitives = { workspace = true } -# substrate deps -sp-consensus-slots = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +sgx_tstd = { workspace = true, features = ["untrusted_time"], optional = true } -# local deps -itp-settings = { path = "../../../core-primitives/settings" } -itp-time-utils = { path = "../../../core-primitives/time-utils", default-features = false } -its-consensus-common = { path = "../common", default-features = false } +sp-consensus-slots = { workspace = true } +sp-runtime = { workspace = true } [dev-dependencies] -itc-parentchain-test = { path = "../../../core/parentchain/test" } -its-test = { path = "../../test" } -sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -itp-test = { path = "../../../core-primitives/test" } +itc-parentchain-test = { workspace = true, features = ["std"] } +its-test = { workspace = true, features = ["std"] } +sp-keyring = { workspace = true } +itp-test = { workspace = true, features = ["std"] } tokio = { version = "1.6.1", features = ["full"] } [features] diff --git a/tee-worker/identity/sidechain/fork-tree/Cargo.toml b/tee-worker/identity/sidechain/fork-tree/Cargo.toml index 6b9c4fc561..5a46f89fc9 100644 --- a/tee-worker/identity/sidechain/fork-tree/Cargo.toml +++ b/tee-worker/identity/sidechain/fork-tree/Cargo.toml @@ -11,10 +11,8 @@ documentation = "https://docs.rs/fork-tree" readme = "README.md" [dependencies] -codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"], default-features = false } - -# sgx deps -sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } +codec = { package = "parity-scale-codec", workspace = true } +sgx_tstd = { workspace = true, optional = true } [features] default = ["std"] diff --git a/tee-worker/identity/sidechain/peer-fetch/Cargo.toml b/tee-worker/identity/sidechain/peer-fetch/Cargo.toml index 25098b3c29..25d7b48f7c 100644 --- a/tee-worker/identity/sidechain/peer-fetch/Cargo.toml +++ b/tee-worker/identity/sidechain/peer-fetch/Cargo.toml @@ -8,30 +8,35 @@ edition = "2021" # crates.io async-trait = { version = "0.1.50" } jsonrpsee = { version = "0.2.0", features = ["client", "ws-server", "macros"] } -log = { version = "0.4" } -serde = "1.0" -serde_json = "1.0" -thiserror = { version = "1.0" } +log = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } -# local -itc-rpc-client = { path = "../../core/rpc-client" } -itp-node-api = { path = "../../core-primitives/node-api" } -itp-types = { path = "../../core-primitives/types" } -its-primitives = { path = "../primitives" } -its-rpc-handler = { path = "../rpc-handler" } -its-storage = { path = "../storage" } +itc-rpc-client = { workspace = true } +itp-node-api = { workspace = true } +itp-types = { workspace = true } +its-primitives = { workspace = true } +its-rpc-handler = { workspace = true } +its-storage = { workspace = true } [dev-dependencies] -# crates.io anyhow = "1.0.40" tokio = { version = "1.6.1", features = ["full"] } -# local -itp-node-api = { path = "../../core-primitives/node-api", features = ["mocks"] } -itp-test = { path = "../../core-primitives/test" } -its-storage = { path = "../storage", features = ["mocks"] } -its-test = { path = "../test" } +itp-node-api = { workspace = true, features = ["std", "mocks"] } +itp-test = { workspace = true, features = ["std"] } +its-storage = { workspace = true, features = ["mocks"] } +its-test = { workspace = true, features = ["std"] } [features] default = ["std"] -std = [] +std = [ + "log/std", + "serde/std", + "serde_json/std", + "itp-node-api/std", + "itp-types/std", + "its-primitives/std", + "its-rpc-handler/std", +] mocks = [] diff --git a/tee-worker/identity/sidechain/primitives/Cargo.toml b/tee-worker/identity/sidechain/primitives/Cargo.toml index 72acc782ad..dd2e7a4cd2 100644 --- a/tee-worker/identity/sidechain/primitives/Cargo.toml +++ b/tee-worker/identity/sidechain/primitives/Cargo.toml @@ -8,16 +8,14 @@ license = "Apache-2.0" edition = "2021" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] } -itp-types = { path = "../../core-primitives/types", default-features = false } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.13", default-features = false } - -# substrate dependencies -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +codec = { package = "parity-scale-codec", workspace = true, features = ["full"] } +itp-types = { workspace = true } +scale-info = { workspace = true } +serde = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } [features] default = ["std", "full_crypto"] diff --git a/tee-worker/identity/sidechain/rpc-handler/Cargo.toml b/tee-worker/identity/sidechain/rpc-handler/Cargo.toml index 2595a732d8..02446faea3 100644 --- a/tee-worker/identity/sidechain/rpc-handler/Cargo.toml +++ b/tee-worker/identity/sidechain/rpc-handler/Cargo.toml @@ -5,35 +5,30 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG '] edition = "2021" +[dependencies] +its-block-composer = { workspace = true } +its-consensus-aura = { workspace = true } +its-consensus-common = { workspace = true } +its-consensus-slots = { workspace = true } +its-primitives = { workspace = true } +its-rpc-handler = { workspace = true } +its-state = { workspace = true } +its-validateer-fetch = { workspace = true } + [features] default = ["std"] std = [ @@ -24,13 +34,3 @@ sgx = [ "its-rpc-handler/sgx", "its-state/sgx", ] - -[dependencies] -its-block-composer = { path = "../block-composer", default-features = false } -its-consensus-aura = { path = "../consensus/aura", default-features = false } -its-consensus-common = { path = "../consensus/common", default-features = false } -its-consensus-slots = { path = "../consensus/slots", default-features = false } -its-primitives = { path = "../primitives", default-features = false } -its-rpc-handler = { path = "../rpc-handler", default-features = false } -its-state = { path = "../state", default-features = false } -its-validateer-fetch = { path = "../validateer-fetch", default-features = false } diff --git a/tee-worker/identity/sidechain/state/Cargo.toml b/tee-worker/identity/sidechain/state/Cargo.toml index 14b166658f..dd68c02583 100644 --- a/tee-worker/identity/sidechain/state/Cargo.toml +++ b/tee-worker/identity/sidechain/state/Cargo.toml @@ -5,28 +5,21 @@ authors = ['Trust Computing GmbH ', 'Integritee AG ', 'Integritee AG ', 'Integritee AG