Skip to content

Commit

Permalink
add missing dcap arg within dockerfile (#3004)
Browse files Browse the repository at this point in the history
* add missing arg within dockerfile

* copy missing protobuf

* fix: use dynamic date for unit test (#3015)

Co-authored-by: higherordertech <higherordertech>

* add dcap as default feature

---------

Co-authored-by: will.li <120463031+higherordertech@users.noreply.github.com>
  • Loading branch information
BillyWooo and higherordertech committed Aug 27, 2024
1 parent d0ac733 commit 569e669
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 99 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -648,15 +650,15 @@ jobs:
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.5

parachain-dynamic-contract-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- 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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/create-release-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bitacross-worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions bitacross-worker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tee-worker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tee-worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tee-worker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tee-worker/litentry/core/assertion-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 569e669

Please sign in to comment.