diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0de089e8c..915f0acf1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,7 +202,7 @@ jobs: - name: Tee-worker check ts code format working-directory: ./tee-worker/ts-tests run: pnpm run check-format - + - name: Dynamic-contract install npm deps working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic run: pnpm install @@ -440,6 +440,7 @@ jobs: WORKER_ENV_DATA_PROVIDERS_CONFIG=1 WORKER_MOCK_SERVER=1 ADDITIONAL_FEATURES_ARG= + RA_METHOD=dcap - name: Copy caches from the built image if: needs.set-condition.outputs.rebuild_tee == 'true' @@ -539,8 +540,9 @@ jobs: tags: local-builder:latest target: builder build-args: | - WORKER_MODE_ARG=offchain-worker + WORKER_MODE_ARG=offchain-worker ADDITIONAL_FEATURES_ARG= + RA_METHOD=dcap - name: Build worker if: needs.set-condition.outputs.rebuild_bitacross == 'true' @@ -648,7 +650,7 @@ jobs: - name: Fail early if: failure() uses: andymckay/cancel-action@0.5 - + parachain-dynamic-contract-test: runs-on: ubuntu-latest steps: @@ -656,7 +658,7 @@ jobs: - name: Enable corepack and pnpm run: corepack enable && corepack enable pnpm - + - name: Install npm deps working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic run: pnpm install @@ -1025,7 +1027,7 @@ jobs: docker load < litentry-parachain-dev.tar.gz docker load < litentry-identity.tar.gz docker load < litentry-bitacross.tar.gz - + - name: Dockerhub login uses: docker/login-action@v3 with: diff --git a/.github/workflows/create-release-draft.yml b/.github/workflows/create-release-draft.yml index 365e49a82c..072dee6cf2 100644 --- a/.github/workflows/create-release-draft.yml +++ b/.github/workflows/create-release-draft.yml @@ -208,7 +208,6 @@ jobs: SGX_MODE=HW IMAGE_FOR_RELEASE=true SGX_COMMERCIAL_KEY=enclave_key.pem - RA_METHOD=dcap - name: Build worker uses: docker/build-push-action@v6 @@ -277,7 +276,6 @@ jobs: SGX_MODE=HW IMAGE_FOR_RELEASE=true SGX_COMMERCIAL_KEY=enclave_key.pem - RA_METHOD=dcap - name: Build worker uses: docker/build-push-action@v6 diff --git a/bitacross-worker/Makefile b/bitacross-worker/Makefile index e15b35e93d..21b7726e5c 100755 --- a/bitacross-worker/Makefile +++ b/bitacross-worker/Makefile @@ -27,7 +27,7 @@ SGX_PRODUCTION ?= 0 ######## Worker Feature Settings ######## # Set offchain-worker as default feature mode WORKER_MODE ?= offchain-worker -RA_METHOD ?= +RA_METHOD ?= dcap SKIP_WASM_BUILD = 1 # include the build settings from rust-sgx-sdk diff --git a/bitacross-worker/build.Dockerfile b/bitacross-worker/build.Dockerfile index f4318923c0..b775c1b5a9 100644 --- a/bitacross-worker/build.Dockerfile +++ b/bitacross-worker/build.Dockerfile @@ -42,6 +42,9 @@ ENV SGX_PRODUCTION=$SGX_PRODUCTION ENV HOME=/home/ubuntu +ARG RA_METHOD +ENV RA_METHOD=$RA_METHOD + ARG WORKER_MODE_ARG ENV WORKER_MODE=$WORKER_MODE_ARG @@ -107,6 +110,7 @@ COPY --from=local-builder:latest /home/ubuntu/bitacross-worker/bin/* /usr/local/ COPY --from=local-builder:latest /home/ubuntu/bitacross-worker/cli/*.sh /usr/local/worker-cli/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/ +COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/ RUN touch spid.txt key.txt RUN chmod +x /usr/local/bin/bitacross-worker @@ -145,6 +149,7 @@ RUN groupadd -g 121 sgx_prv && \ COPY --from=local-builder:latest /opt/sgxsdk /opt/sgxsdk COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/ +COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/ ENV DEBIAN_FRONTEND noninteractive ENV TERM xterm diff --git a/tee-worker/Cargo.lock b/tee-worker/Cargo.lock index a781d94c9b..edf030e078 100644 --- a/tee-worker/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -4424,6 +4424,7 @@ name = "lc-assertion-build" version = "0.1.0" dependencies = [ "blake2-rfc", + "chrono 0.4.38", "env_logger 0.10.0", "ethabi", "frame-support", diff --git a/tee-worker/Makefile b/tee-worker/Makefile index d937bd0b2b..7502ad23ae 100755 --- a/tee-worker/Makefile +++ b/tee-worker/Makefile @@ -30,7 +30,7 @@ SGX_PRODUCTION ?= 0 WORKER_MODE ?= sidechain WORKER_DEV ?= 0 WORKER_MOCK_SERVER ?= 0 -RA_METHOD ?= +RA_METHOD ?= dcap SKIP_WASM_BUILD = 1 # include the build settings from rust-sgx-sdk diff --git a/tee-worker/build.Dockerfile b/tee-worker/build.Dockerfile index e36071a5aa..80f73d6115 100644 --- a/tee-worker/build.Dockerfile +++ b/tee-worker/build.Dockerfile @@ -41,6 +41,9 @@ ENV SGX_PRODUCTION=$SGX_PRODUCTION ENV HOME=/home/ubuntu +ARG RA_METHOD +ENV RA_METHOD=$RA_METHOD + ARG WORKER_MODE_ARG ENV WORKER_MODE=$WORKER_MODE_ARG @@ -123,6 +126,7 @@ COPY --from=local-builder:latest /home/ubuntu/tee-worker/bin/* /usr/local/bin COPY --from=local-builder:latest /home/ubuntu/tee-worker/cli/*.sh /usr/local/worker-cli/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/ +COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/ RUN touch spid.txt key.txt RUN chmod +x /usr/local/bin/litentry-worker @@ -161,6 +165,7 @@ RUN groupadd -g 121 sgx_prv && \ COPY --from=local-builder:latest /opt/sgxsdk /opt/sgxsdk COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/ COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/ +COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/ ENV DEBIAN_FRONTEND noninteractive ENV TERM xterm diff --git a/tee-worker/litentry/core/assertion-build/Cargo.toml b/tee-worker/litentry/core/assertion-build/Cargo.toml index 58339402a7..8a4d1e0d1b 100644 --- a/tee-worker/litentry/core/assertion-build/Cargo.toml +++ b/tee-worker/litentry/core/assertion-build/Cargo.toml @@ -53,6 +53,7 @@ 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 } [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 = "../../../../primitives/hex" } diff --git a/tee-worker/litentry/core/assertion-build/src/nodereal/bnb_domain/mod.rs b/tee-worker/litentry/core/assertion-build/src/nodereal/bnb_domain/mod.rs index 7958eee5f8..39258e8c3b 100644 --- a/tee-worker/litentry/core/assertion-build/src/nodereal/bnb_domain/mod.rs +++ b/tee-worker/litentry/core/assertion-build/src/nodereal/bnb_domain/mod.rs @@ -181,99 +181,107 @@ impl Domains { #[cfg(test)] mod tests { use super::Domains; + use chrono::{Duration, SecondsFormat, Utc}; use litentry_primitives::BnbDigitDomainType; - const RESPONSE: &'static str = r#" - { - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe1": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "1", - "expires": "2024-08-24T00:36:44Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "2", - "expires": "2032-08-24T00:15:56Z" - } - ], - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe2": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "3", - "expires": "2023-08-24T20:36:26Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "4", - "expires": "2023-08-24T20:35:59Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "win", - "expires": "2023-08-24T20:38:29Z" - } - ], - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe3": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "5", - "expires": "2024-08-24T06:33:32Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "6", - "expires": "2024-08-24T07:57:41Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "7", - "expires": "2023-09-16T19:36:14Z" - } - ], - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe4": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "8", - "expires": "2028-09-18T13:35:38Z" - } - ], - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe5": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "9", - "expires": "2023-09-03T08:35:40Z" - } - ], - "0xr4b0bf28adfcee93c5069982a895785c9231c1fe6": [ - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "000", - "expires": "2024-10-30T18:40:51Z" - }, - { - "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", - "name": "999", - "expires": "2024-03-19T18:16:59Z" - } - ] - } - "#; - fn new_domains() -> Domains { - let value: serde_json::Value = serde_json::from_str(RESPONSE).unwrap(); + let future_date = Utc::now() + .checked_add_signed(Duration::days(10)) + .expect("Failed to add duration") + .to_rfc3339_opts(SecondsFormat::Secs, true); + let response = format!( + r#" + {{ + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe1": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "1", + "expires": "2024-08-24T00:36:44Z" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "2", + "expires": "{}" + }} + ], + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe2": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "3", + "expires": "2023-08-24T20:36:26Z" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "4", + "expires": "2023-08-24T20:35:59Z" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "win", + "expires": "2023-08-24T20:38:29Z" + }} + ], + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe3": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "5", + "expires": "2024-08-24T06:33:32Z" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "6", + "expires": "2024-08-24T07:57:41Z" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "7", + "expires": "2023-09-16T19:36:14Z" + }} + ], + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe4": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "8", + "expires": "{}" + }} + ], + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe5": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "9", + "expires": "2023-09-03T08:35:40Z" + }} + ], + "0xr4b0bf28adfcee93c5069982a895785c9231c1fe6": [ + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "000", + "expires": "{}" + }}, + {{ + "nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe", + "name": "999", + "expires": "2024-03-19T18:16:59Z" + }} + ] + }} + "#, + future_date, future_date, future_date + ); + + let value: serde_json::Value = serde_json::from_str(response.as_str()).unwrap(); Domains::from_value(&value).unwrap() }