-
Notifications
You must be signed in to change notification settings - Fork 2
add covenants example with dockerfile for nitro enclave #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| /target | ||
| Cargo.lock | ||
| **/target | ||
| **/Cargo.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,3 +28,9 @@ sha2 = "0.10.9" | |
|
|
||
| [dev-dependencies] | ||
| bitcoinkernel = "0.0.22" | ||
|
|
||
|
|
||
| [workspace] | ||
| members = [ | ||
| "examples" | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| FROM ubuntu:24.04 AS builder | ||
|
|
||
| ARG RUST=1.89.0 | ||
| ARG ZIG_VER=0.14.1 | ||
| ARG TARGET=aarch64-unknown-linux-musl | ||
|
|
||
| RUN apt-get update && apt-get install -y \ | ||
| curl xz-utils cmake libboost1.83-dev libclang-17-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN curl -fSL "https://ziglang.org/download/${ZIG_VER}/zig-aarch64-linux-${ZIG_VER}.tar.xz" -o /tmp/zig.tar.xz \ | ||
| && tar -C /opt -xJf /tmp/zig.tar.xz \ | ||
| && mv /opt/zig-aarch64-linux-* /opt/zig \ | ||
| && ln -sf /opt/zig/zig /usr/local/bin/zig \ | ||
| && rm /tmp/zig.tar.xz | ||
|
|
||
| RUN curl -sSf https://sh.rustup.rs | RUSTUP_INIT_SKIP_PATH_CHECK=yes sh -s -- -y --profile minimal --default-toolchain "${RUST}" \ | ||
| && /root/.cargo/bin/rustup target add "${TARGET}" \ | ||
| && /root/.cargo/bin/cargo install --locked cargo-zigbuild | ||
| ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
|
||
| ENV ZIG_TARGET=aarch64-linux-musl | ||
| ENV CC="zig cc -target ${ZIG_TARGET}" | ||
| ENV CXX="zig c++ -target ${ZIG_TARGET}" | ||
| ENV CXXFLAGS="-UNDEBUG" | ||
|
|
||
| WORKDIR /app | ||
| COPY . ./ | ||
|
|
||
| ENV Boost_DIR=/usr/lib/aarch64-linux-gnu/cmake/Boost-1.83.0 | ||
|
|
||
| RUN cargo zigbuild --release --target aarch64-unknown-linux-musl -p examples --bin covenants_example | ||
|
|
||
| FROM alpine:3.22.1 | ||
| COPY --from=builder /app/target/*/release/covenants_example /covenants_example | ||
| CMD ["/covenants_example","--port","5005"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [package] | ||
| name = "examples" | ||
| version = "0.0.1" | ||
| edition = "2021" | ||
| publish = false | ||
|
|
||
| [[bin]] | ||
| name = "covenants_example" | ||
| path = "src/covenants_example.rs" | ||
|
|
||
| [dependencies] | ||
| bitcoin = { version = "0.32.7", features = ["serde"] } | ||
| serde = { version = "1.0", features = ["derive"] } | ||
| vsock = "0.5.1" | ||
| serde_json = "1.0" | ||
| bitcoinkernel-covenants = "0.0.23" | ||
| confidential-script-lib = { path = "../" } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My instinct is that examples should point to the latest version of the published library. That way users can just copy the example and run it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated Cargo.toml to use the latest verson of the |
||
| hex = "0.4.3" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Covenants Example | ||
|
|
||
| > **Experimental build using [`bitcoinkernel-covenants`](https://github.com/stutxo/rust-bitcoinkernel-covenants)** with OP_CAT, OP_CSFS and OP_CTV enabled | ||
| > Not intended for production use. Use at your own risk. | ||
|
|
||
| ## Run Tests | ||
|
|
||
| ```bash | ||
| cargo test | ||
| ``` | ||
|
|
||
| ## Build Docker Image for Nitro Enclave | ||
|
|
||
| ```bash | ||
| docker build -f Dockerfile.example -t covenants-example . | ||
| ``` | ||
|
|
||
| ## Build and Run Nitro Enclave | ||
|
|
||
| ```bash | ||
| # Build the enclave image | ||
| nitro-cli build-enclave \ | ||
| --docker-uri covenants-example \ | ||
| --output-file covenants_example.eif | ||
|
|
||
| # Run the enclave with specified CPU, memory, and CID | ||
| nitro-cli run-enclave \ | ||
| --cpu-count 2 \ | ||
| --memory 512 \ | ||
| --enclave-cid 16 \ | ||
| --eif-path covenants_example.eif \ | ||
| --debug-mode | ||
|
|
||
| # Inspect running enclaves | ||
| nitro-cli describe-enclaves | ||
|
|
||
| # Connect to the enclave console (replace <id> with the Enclave ID) | ||
| nitro-cli console --enclave-id <id> | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice example using Zig.