Skip to content

Commit

Permalink
remove db dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai committed Oct 16, 2024
1 parent 8765c27 commit d2c16b7
Show file tree
Hide file tree
Showing 38 changed files with 748 additions and 1,131 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/target/
8 changes: 1 addition & 7 deletions .github/workflows/risc0-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Setup Docker and Colima
if: startsWith(matrix.os, 'macos-latest') == true
run: |
brew install docker colima
colima start
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -70,7 +64,7 @@ jobs:

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
Expand Down
27 changes: 0 additions & 27 deletions Dockerfile

This file was deleted.

31 changes: 15 additions & 16 deletions proto/vm_runtime.proto
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
syntax = "proto3";
package vm_runtime;
package vm;

service VmRuntime {
rpc Create(CreateRequest) returns (CreateResponse);
rpc Execute(ExecuteRequest) returns (ExecuteResponse);
service VM {
rpc NewProject(NewProjectRequest) returns (NewProjectResponse);
rpc ExecuteTask(ExecuteTaskRequest) returns (ExecuteTaskResponse);
}

message CreateRequest {
message NewProjectRequest {
uint64 projectID = 1;
string content = 2;
string expParam = 3;
string projectVersion = 2;
bytes binary = 3;
bytes metadata = 4;
}

message CreateResponse {
}

message ExecuteRequest {
message NewProjectResponse {}

message ExecuteTaskRequest {
uint64 projectID = 1;
uint64 taskID = 2;
string clientID = 3;
string sequencerSignature = 4;
repeated string datas = 5;
string projectVersion = 2;
bytes taskID = 3;
repeated bytes payloads = 4;
}

message ExecuteResponse {
message ExecuteTaskResponse {
bytes result = 1;
}
1 change: 0 additions & 1 deletion risc0-server/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
DATABASE_URL=postgres://test_user:[email protected]:5432/test?sslmode=disable
CHAIN_ENDPOINT = "https://babel-api.mainnet.iotex.io"
VERIFY_CONTRACT = "0x79F3872E3e69B696d7ebFAF12691130EfA12291e"
BONSAI_URL = "https://api.bonsai.xyz"
Expand Down
7 changes: 0 additions & 7 deletions risc0-server/BaseDockerfile

This file was deleted.

34 changes: 10 additions & 24 deletions risc0-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,34 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
risc0-zkvm ={ version = "1.0" }
risc0-zkvm = { version = "1.0" }
# bonsai-ethereum-relay = { version = "0.6.1" }
# risc0-ethereum-relay = { git = "https://github.com/risc0/risc0-ethereum.git", rev = "v0.10.0", package = "risc0-ethereum-relay" }
risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v1.0.0" }
# bonsai-sdk = { version = "0.9.0" }

rust-grpc = { path = "../rust-grpc" }

axum = { version = "0.6.20", features = ["multipart","headers", "ws"] }
tokio = { version = "1.0", features = ["full"] }
tower-http = { version = "0.2.0", features = ["fs", "trace"] }
futures = "0.3"
tokio-stream = "0.1"
headers = "0.3"
tracing = "0.1"
tracing-subscriber = { version="0.3", features = ["env-filter", "tracing-log", "fmt"] }
axum_typed_multipart = "0.8.0"
tempfile = "3.7.1"

tracing-subscriber = { version = "0.3", features = [
"env-filter",
"tracing-log",
"fmt",
] }
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
diesel = { version = "2.1.0", features = ["postgres", "r2d2"] }
dotenvy = "0.15"
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
bincode = "1.3"
anyhow = { version = "1.0", default-features = false }
bytemuck = { version = "1.13", features = ["extern_crate_alloc"] }
ethers = { version = "2.0", features = ["rustls", "ws"] }
web3 = "0.19.0"
flate2 = "1.0.20"
rustc-hex = "2.1.0"
tonic = "0.8"
tonic-reflection = "0.6.0"
prost = "0.11"
diesel_migrations = "2.2.0"
tonic = "0.12.3"
lazy_static = "=1.4.0"
regex = "1.11.0"
dyn-clone = "1.0.17"

[dev-dependencies]
lazy_static = "=1.4.0"

[build-dependencies]
tonic-build = "0.8"

[features]
cuda = ["risc0-zkvm/cuda"]
Expand Down
41 changes: 22 additions & 19 deletions risc0-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# Use the official Rust image as the base image
FROM rust:1.79.0 AS builder

RUN update-ca-certificates

RUN apt update
RUN apt install -y curl libpq-dev libssl-dev libpq-dev librust-openssl-dev librust-openssl-sys-dev
RUN apt -y install libpq5
RUN apt update && apt install -y libprotobuf-dev protobuf-compiler

RUN cargo install diesel_cli --no-default-features --features postgres --version 2.1.0
# Set the working directory inside the container
WORKDIR /usr/src/app

RUN curl -L https://foundry.paradigm.xyz | bash
RUN /root/.foundry/bin/foundryup
RUN cp /root/.foundry/bin/* /usr/bin/
RUN apt update && apt install -y libprotobuf-dev protobuf-compiler

WORKDIR /rust/src
COPY ./ ./
# Copy the Cargo.toml and Cargo.lock files
# COPY Cargo.toml Cargo.lock ./

RUN export CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN export RUST_BACKTRACE=1
# Copy the source code
COPY ./risc0-server ./risc0-server
COPY ./rust-grpc ./rust-grpc
COPY ./proto ./proto

# Build the project
RUN cd risc0-server && cargo build --release

# Use a minimal base image for the final stage
FROM debian:bullseye-slim


FROM wangweixiaohao2944/risc0serverbase:v1.0.0
# Install ca-certificates without cache
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /risc0server/

# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/app/risc0-server/target/release/risc0-server /usr/local/bin/risc0-server

COPY --from=builder /rust/src/risc0-server/target/release/risc0-server ./
COPY ./risc0-server/Cargo.toml /risc0server/
COPY ./risc0-server/diesel.toml /risc0server/
COPY ./risc0-server/verify_contract_abi.json /risc0server/
# Expose the port that the server will run on
EXPOSE 4001

CMD ["/risc0server/risc0-server"]
# Set the entrypoint to the compiled binary
CMD ["risc0-server"]
18 changes: 0 additions & 18 deletions risc0-server/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@


integration_test_depends_stop:
@docker stop postgres_test || true && docker container rm postgres_test || true

.PHONY: integration_test_depends
integration_test_depends: integration_test_depends_stop postgres_test risc0_depends

.PHONY: postgres_test
postgres_test:
docker run --name postgres_test \
-e POSTGRES_USER=test_user \
-e POSTGRES_PASSWORD=test_passwd \
-e POSTGRES_DB=test \
-p 15432:5432 \
-d postgres:14

.PHONY: risc0_depends
risc0_depends:
cargo install cargo-binstall
echo yes | cargo binstall cargo-risczero
cargo risczero install

integration_test: integration_test_depends
@cd risc0-server/ && cargo test
23 changes: 3 additions & 20 deletions risc0-server/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# risc0-server

## setup
### install diesel

``` shell
cargo install diesel_cli --no-default-features --features postgres
```


### build release

Expand All @@ -16,22 +12,9 @@ cargo build --release
### configure database
modify `.env` file

``` shell
DATABASE_URL=postgres://test_user:[email protected]:5432/test?sslmode=disable
```

### migrate database

``` shell
diesel setup

diesel migration generate risc0-server

diesel migration run
```


### run risc0 rpc sever

``` shell
./target/release/risc0server
./target/release/risc0-server
```
9 changes: 0 additions & 9 deletions risc0-server/diesel.toml

This file was deleted.

Empty file removed risc0-server/migrations/.keep
Empty file.

This file was deleted.

21 changes: 0 additions & 21 deletions risc0-server/migrations/2024-03-28-110112_risc0-server/up.sql

This file was deleted.

2 changes: 1 addition & 1 deletion risc0-server/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod prove;
pub mod prover;
52 changes: 0 additions & 52 deletions risc0-server/src/core/prove.rs

This file was deleted.

Loading

0 comments on commit d2c16b7

Please sign in to comment.