Skip to content

Commit

Permalink
bitacross init (#2419)
Browse files Browse the repository at this point in the history
* bitacross init

* add ci fmt

* fmt

* comment out docker upload job

* comment out docker image based jobs

* more adjustments

* remove parachain dependency on tee (#2433)

* adjust crate name

* P-54 Binary search for holding time assertion (#2401)

Co-authored-by: Kailai Wang <kailai.wang@trustcomputing.de>
Co-authored-by: Zhouhui Tian <zhouhui@liteng.io>

* clippy fix

---------

Co-authored-by: Zhouhui Tian <125243011+zhouhuitian@users.noreply.github.com>
Co-authored-by: Ariel Birnbaum <ariel@litentry.com>
Co-authored-by: Kailai Wang <kailai.wang@trustcomputing.de>
Co-authored-by: Zhouhui Tian <zhouhui@liteng.io>
Co-authored-by: Kai <7630809+Kailai-Wang@users.noreply.github.com>
  • Loading branch information
6 people committed Jan 30, 2024
1 parent 118b195 commit 28167f6
Show file tree
Hide file tree
Showing 913 changed files with 123,307 additions and 7 deletions.
14 changes: 14 additions & 0 deletions .github/file-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ tee_test: &tee_test
- 'tee-worker/cli/*.sh'
- 'docker/**'
- 'tee-worker/docker/*.yml'

bitacross_src: &bitacross_src
- 'bitacross-worker/**/*.rs'
- 'bitacross-worker/**/Cargo.toml'
- 'bitacross-worker/**/Cargo.lock'
- 'bitacross-worker/**/rust-toolchain.toml'
- 'bitacross-worker/build.Dockerfile'
- 'bitacross-worker/enclave-runtime/**'

bitacross_test: &bitacross_src
- 'bitacross-worker/ts-tests/**'
- 'bitacross-worker/cli/*.sh'
- 'docker/**'
- 'bitacross-worker/docker/*.yml'
86 changes: 83 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ jobs:
outputs:
rebuild_parachain: ${{ steps.env.outputs.rebuild_parachain }}
rebuild_tee: ${{ steps.env.outputs.rebuild_tee }}
rebuild_bitacross: ${{ steps.env.outputs.rebuild_bitacross }}
push_docker: ${{ steps.env.outputs.push_docker }}
run_parachain_test: ${{ steps.env.outputs.run_parachain_test }}
run_tee_test: ${{ steps.env.outputs.run_tee_test }}
run_bitacross_test: ${{ steps.env.outputs.run_bitacross_test }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -105,6 +107,7 @@ jobs:
run: |
rebuild_parachain=false
rebuild_tee=false
rebuild_bitacross=false
push_docker=false
run_parachain_test=false
run_tee_test=false
Expand All @@ -114,6 +117,9 @@ jobs:
if [ "${{ github.event.inputs.rebuild-tee-docker }}" = "true" ] || [ "${{ steps.filter.outputs.tee_src }}" = "true" ]; then
rebuild_tee=true
fi
if [ "${{ github.event.inputs.rebuild-bitacross-docker }}" = "true" ] || [ "${{ steps.filter.outputs.bitacross_src }}" = "true" ]; then
rebuild_bitacross=true
fi
if [ "${{ github.event.inputs.push-docker }}" = "true" ]; then
push_docker=true
elif [ "${{ github.event_name }}" = 'push' ] && [ "${{ github.ref }}" = 'refs/heads/dev' ]; then
Expand All @@ -125,11 +131,16 @@ jobs:
if [ "${{ steps.filter.outputs.tee_test }}" = "true" ] || [ "$rebuild_parachain" = "true" ] || [ "$rebuild_tee" = "true" ]; then
run_tee_test=true
fi
if [ "${{ steps.filter.outputs.bitacross_test }}" = "true" ] || [ "$rebuild_parachain" = "true" ] || [ "$rebuild_bitacross" = "true" ]; then
run_bitacross_test=true
fi
echo "rebuild_parachain=$rebuild_parachain" | tee -a $GITHUB_OUTPUT
echo "rebuild_tee=$rebuild_tee" | tee -a $GITHUB_OUTPUT
echo "rebuild_bitacross=$rebuild_bitacross" | tee -a $GITHUB_OUTPUT
echo "push_docker=$push_docker" | tee -a $GITHUB_OUTPUT
echo "run_parachain_test=$run_parachain_test" | tee -a $GITHUB_OUTPUT
echo "run_tee_test=$run_tee_test" | tee -a $GITHUB_OUTPUT
echo "run_bitacross_test=$$run_tee_test" | tee -a $GITHUB_OUTPUT
fmt:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -159,11 +170,22 @@ jobs:
cargo fmt --all -- --check
taplo fmt --check
- name: Enclave-runtime fmt check
- name: Tee-worker enclave-runtime fmt check
working-directory: ./tee-worker/enclave-runtime
run: |
cargo fmt --all -- --check
- name: bitacross-worker fmt check
working-directory: ./bitacross-worker
run: |
cargo fmt --all -- --check
taplo fmt --check
- name: bitacross-worker enclave-runtime fmt check
working-directory: ./bitacross-worker/enclave-runtime
run: |
cargo fmt --all -- --check
- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm

Expand Down Expand Up @@ -282,6 +304,66 @@ jobs:
if: failure()
uses: andymckay/cancel-action@0.3

bitacross-clippy:
runs-on: ubuntu-latest
needs:
- fmt
- set-condition
- sequentialise
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
# todo: we might want to change this image in the future
container: "litentry/litentry-tee-dev:latest"
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
- name: bitacross-worker clippy
working-directory: ./bitacross-worker
run: |
echo "::group::cargo clippy all"
cargo clippy --release -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy sidechain"
cargo clippy --release --features sidechain -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy offchain-worker"
cargo clean --profile release
cargo clippy --release --features offchain-worker -- -D warnings
echo "::endgroup::"
- name: Clean up disk
working-directory: ./bitacross-worker
run: |
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
cargo clean --profile release
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
- name: bitacross-enclave clippy
working-directory: ./bitacross-worker/enclave-runtime
run: |
echo "::group::cargo clippy all"
cargo clippy --release -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy sidechain"
cargo clippy --release --features sidechain -- -D warnings
echo "::endgroup::"
echo "::group::cargo clippy offchain-worker"
cargo clean --profile release
cargo clippy --release --features offchain-worker -- -D warnings
echo "::endgroup::"
- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.3

parachain-build-dev:
runs-on: ubuntu-latest
needs:
Expand Down Expand Up @@ -378,7 +460,6 @@ jobs:
echo "::group::Show disk usage"
df -h .
echo "::endgroup::"
# cache mount in buildkit won't be exported as image layers, so it doesn't work well with GHA cache, see
# https://github.com/moby/buildkit/issues/1512
# https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/
Expand Down Expand Up @@ -468,7 +549,6 @@ jobs:
name: litentry-tee
path: litentry-tee.tar.gz
if-no-files-found: error

- name: Fail early
if: failure()
uses: andymckay/cancel-action@0.3
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ fmt-cargo:
@cargo fmt --all
@cd tee-worker && cargo fmt --all
@cd tee-worker/enclave-runtime && cargo fmt --all
@cd bitacross-worker && cargo fmt --all
@cd bitacross-worker/enclave-runtime && cargo fmt --all

.PHONY: fmt-taplo ## taplo fmt
fmt-taplo:
Expand Down
16 changes: 16 additions & 0 deletions bitacross-worker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Litentry note: this file is unused
# Please edit the ../.dockerignore directly
.git
.githooks
.github
.idea
ci/
docker/*yml
docs/
local-setup/
scripts/
target/
enclave-runtime/target/
tmp/
*.Dockerfile
Dockerfile
27 changes: 27 additions & 0 deletions bitacross-worker/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
indent_style = tab
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
max_line_length = 100
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf

[*.ts]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf


[*.toml]
indent_style = space
14 changes: 14 additions & 0 deletions bitacross-worker/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AliceWSPort=9946
AliceRPCPort=9936
AlicePort=30336
BobWSPort=9947
BobRPCPort=9937
BobPort=30337
CollatorWSPort=9944
CollatorRPCPort=9933
CollatorPort=30333
TrustedWorkerPort=2000
UntrustedWorkerPort=2001
MuRaPort=3443
UntrustedHttpPort=4545
NODE_ENV=local
18 changes: 18 additions & 0 deletions bitacross-worker/.gitattributes.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# TODO: why do we need binary mode for Cargo.lock?
# Cargo.lock linguist-generated=true -diff

[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4

* text=auto eol=lf
*.cpp rust
*.h rust
*.rs rust
*.fixed linguist-language=Rust
src/etc/installer/gfx/* binary
*.woff binary
src/vendor/** -text
Cargo.lock -merge linguist-generated=false

# Older git versions try to fix line endings on images, this prevents it.
*.png binary
*.ico binary
17 changes: 17 additions & 0 deletions bitacross-worker/.githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# This pre-commit hook uses cargo fmt to check the code style
# Install it either with `make githooks` or copy the file to .git/hooks

echo '+cargo fmt -- --check'
cargo fmt -- --check
result=$?

if [[ ${result} -ne 0 ]] ; then
cat <<\EOF
There are some code style issues, run `cargo fmt` first.
EOF
exit 1
fi

exit 0
Loading

0 comments on commit 28167f6

Please sign in to comment.