Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build match worker image #2313

Merged
merged 47 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7d260a6
add worker && cli build
0xverin Dec 6, 2023
eb2b57f
separate docker builds
0xverin Dec 6, 2023
88e84b4
add Docker Buildx
0xverin Dec 6, 2023
a1373de
add caches
0xverin Dec 6, 2023
bb277e0
free up disk space
0xverin Dec 6, 2023
eba2b33
remove caches
0xverin Dec 6, 2023
cf32267
build local builder
0xverin Dec 6, 2023
c5be054
re-base worker-cache
0xverin Dec 6, 2023
cb33d19
push docker image
0xverin Dec 6, 2023
636efd8
change condition
0xverin Dec 6, 2023
a82bc50
uncomment
0xverin Dec 6, 2023
9080e64
improve worker tag
0xverin Dec 11, 2023
8ec2d88
remove hardcode
0xverin Dec 11, 2023
773df6a
sort && rename
0xverin Dec 11, 2023
a8945b0
fix tag
0xverin Dec 11, 2023
293b62b
echo worker tag
0xverin Dec 20, 2023
0d10952
test tag
0xverin Dec 20, 2023
a541f37
run echo
0xverin Dec 20, 2023
8eddcae
echo images
0xverin Dec 20, 2023
063dc77
fix tag issue
0xverin Dec 20, 2023
7bac6ec
test hard code tag
0xverin Dec 20, 2023
059a2ae
fix tag parameters
0xverin Dec 20, 2023
77c8237
uncomment
0xverin Dec 20, 2023
92022de
Merge branch 'dev' into p-330-build-match-worker-image
0xverin Dec 20, 2023
294e04b
Merge branch 'dev' into p-330-build-match-worker-image
0xverin Jan 3, 2024
072baea
Merge branch 'dev' into p-330-build-match-worker-image
Traf333 Jan 11, 2024
e4d6b9d
split parachain and worker versions
Traf333 Jan 12, 2024
0651173
adjust inputs description
Traf333 Jan 12, 2024
a32a5e9
correct version name for draft release
Traf333 Jan 12, 2024
2582d9e
rolback to release version
Traf333 Jan 15, 2024
cf8775f
include patch version to the image
Traf333 Jan 15, 2024
b5e0a84
Merge branch 'dev' into p-330-build-match-worker-image
Traf333 Jan 15, 2024
cae2983
fix included patch number
Traf333 Jan 15, 2024
dea5314
include exception for shorter version
Traf333 Jan 15, 2024
9861dba
simplify ts release package + refactoring
Traf333 Jan 16, 2024
9c05391
fix script typo
Traf333 Jan 16, 2024
6046b55
check without timeout
Traf333 Jan 16, 2024
8924412
debug artefacts
Traf333 Jan 17, 2024
a0054ce
check with started worker
Traf333 Jan 18, 2024
244221e
add comment
Traf333 Jan 19, 2024
ab29516
cleanup
Traf333 Jan 19, 2024
ac3df19
debugging
Traf333 Jan 19, 2024
b86b527
add meaningful comment
Traf333 Jan 19, 2024
15dddb3
uncommit publishing packages
Traf333 Jan 19, 2024
4d8f544
Merge branch 'dev' into p-330-build-match-worker-image
BillyWooo Jan 21, 2024
0b7f59c
Merge branch 'dev' into p-330-build-match-worker-image
0xverin Jan 22, 2024
6658e36
Merge branch 'dev' into p-330-build-match-worker-image
Traf333 Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 134 additions & 18 deletions .github/workflows/create-release-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ on:
required: true
default: true
release_tag:
description: an existing tag for creating release (e.g. v1.2.3)
description: an existing tag for creating release (e.g. p1.2.0-w0.0.1-101)
required: true
diff_tag:
description: an existing tag to run diff against (e.g. v1.2.0)
description: an existing tag to run diff against (e.g. p1.1.0-w0.0.1-100)
default: ""
required: false
genesis_release:
Expand All @@ -44,6 +44,7 @@ env:
DIFF_TAG: ${{ github.event.inputs.diff_tag }}
GENESIS_RELEASE: ${{ github.event.inputs.genesis_release }}
DOCKER_BUILDKIT: 1
REF_VERSION: ${{ github.head_ref || github.ref_name }}

jobs:
set-release-type:
Expand Down Expand Up @@ -114,8 +115,8 @@ jobs:
${{ matrix.chain }}-parachain-srtool-digest.json
${{ matrix.chain }}-parachain-runtime.compact.compressed.wasm

## build docker image of parachain binary ##
build-docker:
# build docker image of parachain binary ##
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to change it to single #? It used the ## ... ## style

build-parachain-docker:
if: ${{ github.event.inputs.release_client == 'true' }}
runs-on: ubuntu-latest
steps:
Expand All @@ -127,7 +128,7 @@ jobs:

- name: Set env
run: |
DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | cut -d'-' -f1 | sed 's/p/v/')
DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | sed 's/p/v/;s/\(.*\)-w.*/\1/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for this, or just a casual change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change the job name from build-docker to build-parachain-docker, we should change the var to PARACHAIN_DOCKER_TAG too, for workers it should be WORKER_DOCKER_TAG - please let's keep the naming consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for this, or just a casual change?
Yes this changes allows us to consider a variety of options for specific versions

  • latest
  • p0.9.18-w0.0.2
  • p0.9.18-9181-w0.0.2-101

echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV

- name: Build docker image
Expand Down Expand Up @@ -166,6 +167,121 @@ jobs:
${{ env.GENESIS_RELEASE }}-genesis-state
${{ env.GENESIS_RELEASE }}-genesis-wasm

build-worker-docker:
if: ${{ github.event.inputs.release_worker == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout codes on ${{ env.RELEASE_TAG }}
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0
- name: Set env
run: |
WORKER_TAG=$(echo ${{ env.RELEASE_TAG }} | sed 's/.*\(w.*\)/\1/;s/w/v/')
echo "WORKER_TAG=$WORKER_TAG" >> $GITHUB_ENV

- name: Free up disk space
if: startsWith(runner.name, 'GitHub Actions')
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
swap-storage: false
large-packages: false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# use the docker driver to access the local image
# we don't need external caches or multi platforms here
# see https://docs.docker.com/build/drivers/
driver: docker

- name: Cache worker-cache
uses: actions/cache@v3
Comment on lines +184 to +201
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For releases I suggest not using any cache at all

with:
path: |
worker-cache
key: worker-cache-${{ env.REF_VERSION }}-${{ hashFiles('tee-worker/**/Cargo.lock', 'tee-worker/**/Cargo.toml') }}
restore-keys: |
worker-cache-${{ env.REF_VERSION }}-
worker-cache-

- name: Create cache folder if not exist
run: |
for i in 'git/db' 'registry/cache' 'registry/index' 'sccache'; do
[ ! -d "worker-cache/$i" ] && mkdir -p "worker-cache/$i" || true
echo "hello" > worker-cache/$i/nix
done
echo "::group::List worker-cache size"
du -sh worker-cache/*
echo "::endgroup::"
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"

- name: Build local builder
uses: docker/build-push-action@v5
with:
context: .
file: tee-worker/build.Dockerfile
tags: local-builder:latest
target: builder
build-args: |
WORKER_MODE_ARG=sidechain
ADDITIONAL_FEATURES_ARG=

- name: Copy caches from the built image
run: |
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
echo "::group::docker images"
docker images --all
echo "::endgroup::"
echo "::group::copy cache out"
for i in 'git/db' 'registry/cache' 'registry/index'; do
b="${i%/*}"
rm -rf worker-cache/$i
docker cp "$(docker create --rm local-builder:latest):/opt/rust/$i" worker-cache/$b
done
rm -rf worker-cache/sccache
docker cp "$(docker create --rm local-builder:latest):/opt/rust/sccache" worker-cache
du -sh worker-cache/*
echo "::endgroup::"
echo "::group::df -h ."
df -h .
echo "::endgroup::"

- name: Build worker
uses: docker/build-push-action@v5
with:
context: .
file: tee-worker/build.Dockerfile
tags: litentry/litentry-worker:${{ env.WORKER_TAG }}
target: deployed-worker

- name: Build cli
uses: docker/build-push-action@v5
with:
context: .
file: tee-worker/build.Dockerfile
tags: litentry/litentry-cli:${{ env.WORKER_TAG }}
target: deployed-client

- run: docker images --all

- name: Dockerhub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Push worker image
run: |
docker push litentry/litentry-worker:$WORKER_TAG
docker push litentry/litentry-cli:$WORKER_TAG

## Build the enclave and package config files
build-tee:
if: ${{ github.event.inputs.release_worker == 'true' }} || ${{ github.event.inputs.release_enclave == 'true' }}
Expand All @@ -181,8 +297,8 @@ jobs:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0

- name: Build release artefacts
run: |
- name: Build release artefacts
run: |
source /opt/intel/sgxsdk/environment
./tee-worker/scripts/litentry/release/build.sh ${{ github.event.inputs.release_worker }} ${{ github.event.inputs.release_enclave }}

Expand Down Expand Up @@ -214,11 +330,11 @@ jobs:
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.3

## test again the built docker image ##
run-ts-tests:
runs-on: ubuntu-latest
needs: build-docker
needs: build-parachain-docker
strategy:
matrix:
chain:
Expand All @@ -235,7 +351,7 @@ jobs:

- name: Download and tag docker image
run: |
export DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | cut -d'-' -f1 | sed 's/p/v/')
export DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | sed 's/p/v/;s/\(.*\)-w.*/\1/')
docker pull litentry/litentry-parachain:$DOCKER_TAG
docker tag litentry/litentry-parachain:$DOCKER_TAG litentry/litentry-parachain:latest

Expand All @@ -260,7 +376,7 @@ jobs:
## check extrinsic ##
extrinsic-ordering-check-from-bin:
runs-on: ubuntu-latest
needs: build-docker
needs: build-parachain-docker
strategy:
matrix:
chain: [rococo, litmus, litentry]
Expand All @@ -280,7 +396,7 @@ jobs:
- name: Prepare output and compare the metadata
timeout-minutes: 3
run: |
export DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | cut -d'-' -f1 | sed 's/p/v/')
export DOCKER_TAG=$(echo ${{ env.RELEASE_TAG }} | sed 's/p/v/;s/\(.*\)-w.*/\1/')
PARACHAIN_NAME=local-parachain
BASE_URL=ws://127.0.0.1:9944
chain=${{ matrix.chain }}
Expand Down Expand Up @@ -310,16 +426,16 @@ jobs:
uses: actions-cool/issues-helper@v3
id: findissueid
with:
actions: 'find-issues'
actions: "find-issues"
token: ${{ secrets.GITHUB_TOKEN }}
issue-state: 'open'
issue-state: "open"
title-includes: Litentry-parachain ${{ env.RELEASE_TAG }} Release checklist

- name: Create comment
if: ${{ steps.findissueid.outputs.issues }} != '[]'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
actions: "create-comment"
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ fromJson(steps.findissueid.outputs.issues)[0].number }}
body: |
Expand All @@ -334,7 +450,7 @@ jobs:
- set-release-type
- build-tee
- run-ts-tests
- build-wasm
- build-wasm
if: |
!failure() &&
(success('build-wasm') || success('run-ts-tests') || success('build-tee'))
Expand All @@ -347,7 +463,7 @@ jobs:

- name: Download all artefacts
uses: actions/download-artifact@v3

- name: Generate release notes
run: |
export MRENCLAVE="${{ needs.build-tee.outputs.mrenclave }}"
Expand Down
41 changes: 18 additions & 23 deletions .github/workflows/release-ts-api-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@ name: Release Ts API Package

on:
workflow_dispatch:
inputs:
parachain-tag:
description: 'Parachain docker image tag'
required: true
default: 'latest'
worker-tag:
description: 'Worker docker image tag'
required: true
default: 'latest'
release-tag:
description: 'Client-api release tag'
required: true
default: 'latest'
inputs:
release-tag:
description: "Client-api release tag (e.g. p1.2.0-9701-w0.0.1-101)"
Copy link
Contributor Author

@0xverin 0xverin Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use the latest version if we change it here, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it won't affect the use of lates version and we still are able to set release tag as latest in order to generate types from latest docker images

required: true
env:
NODE_AUTH_TOKEN: ${{ secrets.RELEASE_TS_API_PACKAGE_TOKEN }}

Expand All @@ -25,18 +16,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set ENV
run: |
# extracting parachain version and worker version from release tag
echo "PARACHAIN_TAG=$(echo ${{inputs.release-tag}} | sed 's/p/v/;s/\(.*\)-w.*/\1/')" >> $GITHUB_ENV
echo "WORKER_TAG=$(echo ${{inputs.release-tag}} | sed 's/.*\(w.*\)/\1/;s/w/v/')" >> $GITHUB_ENV

- name: Pull litentry image optionally
run: |
docker pull parity/polkadot
docker pull litentry/litentry-worker:${{ inputs.worker-tag }}
docker pull litentry/litentry-cli:${{ inputs.worker-tag }}
docker pull litentry/litentry-parachain:${{ inputs.parachain-tag }}
docker pull litentry/litentry-worker:$WORKER_TAG
docker pull litentry/litentry-cli:$WORKER_TAG
docker pull litentry/litentry-parachain:$PARACHAIN_TAG

- name: Re-tag docker image
run: |
docker tag litentry/litentry-worker:${{ inputs.worker-tag }} litentry/litentry-worker:latest
docker tag litentry/litentry-cli:${{ inputs.worker-tag }} litentry/litentry-cli:latest
docker tag litentry/litentry-parachain:${{ inputs.parachain-tag }} litentry/litentry-parachain:latest
docker tag litentry/litentry-worker:$WORKER_TAG litentry/litentry-worker:latest
docker tag litentry/litentry-cli:$WORKER_TAG litentry/litentry-cli:latest
docker tag litentry/litentry-parachain:$PARACHAIN_TAG litentry/litentry-parachain:latest

- run: docker images --all

Expand All @@ -51,9 +48,8 @@ jobs:
run: |
cd tee-worker/docker
docker compose -f litentry-parachain.build.yml build

- name: Update metadata and generate types
timeout-minutes: 10
run: |
cd tee-worker/docker
docker compose -f docker-compose.yml -f lit-ts-api-package-build.yml up --no-build --exit-code-from lit-ts-api-package-build lit-ts-api-package-build
Expand Down Expand Up @@ -83,7 +79,6 @@ jobs:
echo "$api dist and build files do not exist. Publishing failed."
exit 1
fi

npm publish --tag ${{ inputs.release-tag }}

echo "------------------------$api published------------------------"
Expand All @@ -109,4 +104,4 @@ jobs:
with:
name: logs-lit-ts-api-package-build
path: logs
if-no-files-found: ignore
if-no-files-found: ignore
4 changes: 2 additions & 2 deletions tee-worker/cli/lit_ts_api_package_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ echo "Using client binary $CLIENT_BIN"
echo "Using node uri $NODEURL:$NPORT"
echo "Using trusted-worker uri $WORKER1URL:$WORKER1PORT"
echo "Using node http uri $NODEHTTPURL:$NPORT"
echo ""

echo "waiting 20 secs worker to run successfully"
sleep 20
cd /client-api/parachain-api
curl -s -H "Content-Type: application/json" -d '{"id": "1", "jsonrpc": "2.0", "method": "state_getMetadata", "params": []}' $NODEHTTPURL:$NPORT > prepare-build/litentry-parachain-metadata.json
echo "update parachain metadata"
Expand Down
8 changes: 5 additions & 3 deletions tee-worker/docker/lit-ts-api-package-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ services:
litentry-node:
condition: service_healthy
litentry-worker-1:
condition: service_healthy
# using +service_started+ over +service_healthy+ since worker runs successfully but can not connect to parachain
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "3" mean?

# as requires additional pre-setup for parachain image which built in production mode
# for generating types there is no need for fully workable interaction between worker and parachain
condition: service_started
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean we can get the data even tho enclave is not registered on the parachain? (I assume so

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's correct. I have one concern though, what if not registred enclave generate types which are different in case it was registred 🤔

networks:
- litentry-test-network
entrypoint:
"/usr/local/worker-cli/lit_ts_api_package_build.sh -p 9912 -u ws://litentry-node
entrypoint: "/usr/local/worker-cli/lit_ts_api_package_build.sh -p 9912 -u ws://litentry-node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we keep the old format?

-W http://litentry-node -V wss://litentry-worker-1 -A 2011 -C /usr/local/bin/litentry-cli 2>&1"
restart: "no"
networks:
Expand Down