-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'dealer-source/master' into dealer
- Loading branch information
Showing
13 changed files
with
1,021 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: push | ||
|
||
name: Clippy Check | ||
|
||
jobs: | ||
clippy-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- run: rustup component add clippy | ||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: > | ||
--tests | ||
--benches | ||
--all-features -- | ||
-D warnings | ||
-D unsafe_code | ||
-D missing_docs | ||
-D clippy::missing_docs_in_private_items | ||
-D clippy::needless_pass_by_value | ||
-D clippy::needless_pass_by_ref_mut | ||
-D clippy::unused_async |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
on: push | ||
|
||
name: Rustfmt | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
components: rustfmt | ||
override: true | ||
- uses: mbrobbel/rustfmt-check@master | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
on: push | ||
|
||
name: Cargo Test | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
cargo-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
- name: Test | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --workspace --all-features --verbose -- --skip integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
/target | ||
/.gitattributes | ||
|
||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[workspace] | ||
members = ["renegade-dealer", "renegade-dealer-api"] | ||
|
||
[profile.bench] | ||
opt-level = 3 | ||
lto = true | ||
debug = true | ||
|
||
[profile.release] | ||
opt-level = 3 # Full optimizations | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM --platform=arm64 rust:latest AS chef | ||
|
||
WORKDIR /build | ||
COPY ./rust-toolchain ./rust-toolchain | ||
RUN rustup install $(cat rust-toolchain) | ||
|
||
RUN apt-get update && apt-get install -y libssl-dev | ||
|
||
# Install chef and generate a recipe | ||
RUN cargo install cargo-chef | ||
|
||
COPY ./Cargo.toml ./Cargo.toml | ||
COPY ./Cargo.lock ./Cargo.lock | ||
COPY ./renegade-dealer ./renegade-dealer | ||
COPY ./renegade-dealer-api ./renegade-dealer-api | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
# Disable compiler warnings and enable backtraces for panic | ||
ENV RUSTFLAGS=-Awarnings | ||
ENV RUST_BACKTRACE=1 | ||
|
||
# Build only the dependencies to cache them in this layer | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
# Copy back in the full sources and build the tests | ||
WORKDIR /build | ||
COPY ./Cargo.lock ./Cargo.lock | ||
COPY ./renegade-dealer ./renegade-dealer | ||
COPY ./renegade-dealer-api ./renegade-dealer-api | ||
|
||
WORKDIR /build/renegade-dealer | ||
RUN cargo build --release --quiet --all-features | ||
|
||
ENTRYPOINT ["cargo", "run", "--release", "--all-features"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
REGION=ca-central-1 | ||
ENVIRONMENT=${1:-staging} | ||
ECR_URL=377928551571.dkr.ecr.ca-central-1.amazonaws.com/renegade-dealer-$ENVIRONMENT | ||
|
||
docker build -t dealer:latest . | ||
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ECR_URL | ||
|
||
docker tag dealer:latest $ECR_URL:latest | ||
docker push $ECR_URL:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
REGION=ca-central-1 | ||
ENVIRONMENT=${1:-staging} | ||
CLUSTER_NAME=$ENVIRONMENT-renegade-dealer-cluster | ||
SERVICE_NAME=$ENVIRONMENT-renegade-dealer-service | ||
TASK_FAMILY=$ENVIRONMENT-renegade-dealer-task-def | ||
ECR_URL=377928551571.dkr.ecr.ca-central-1.amazonaws.com/renegade-dealer-$ENVIRONMENT | ||
|
||
# Fetch the latest image URI from ECR | ||
IMAGE_URI=$(aws ecr describe-images --repository-name renegade-dealer-$ENVIRONMENT --region $REGION --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) | ||
FULL_IMAGE_URI="$ECR_URL:$IMAGE_URI" | ||
echo "Using image URI: $FULL_IMAGE_URI" | ||
|
||
# Fetch the existing definition of the task and create a new revision with the updated URI | ||
TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition $TASK_FAMILY --region $REGION --query 'taskDefinition') | ||
NEW_TASK_DEF=$(echo $TASK_DEFINITION | \ | ||
jq --arg IMAGE_URI "$FULL_IMAGE_URI" '.containerDefinitions[0].image = $IMAGE_URI' | \ | ||
jq 'del(.taskDefinitionArn)' | \ | ||
jq 'del(.revision)' | \ | ||
jq 'del(.status)' | \ | ||
jq 'del(.requiresAttributes)' | \ | ||
jq 'del(.compatibilities)' | \ | ||
jq 'del(.registeredAt)' | \ | ||
jq 'del(.registeredBy)' | \ | ||
jq -c) | ||
|
||
# Register the new task definition | ||
NEW_TASK_INFO=$(aws ecs register-task-definition --cli-input-json "$NEW_TASK_DEF" --region $REGION) | ||
NEW_REVISION=$(echo $NEW_TASK_INFO | jq -r '.taskDefinition.revision') | ||
echo "Created new task revision: $NEW_REVISION" | ||
|
||
# Update the ECS cluster to the new revision | ||
aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --task-definition $TASK_FAMILY:$NEW_REVISION --region $REGION >/dev/null 2>&1 | ||
echo "ECS cluster updated to new revision" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "renegade-dealer-api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ark-bn254 = "0.4.0" | ||
ark-mpc = { git = "https://github.com/renegade-fi/ark-mpc.git" } | ||
|
||
k256 = "0.13" | ||
|
||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
uuid = "1.8" | ||
|
||
[dev-dependencies] | ||
rand = "0.8" |
Oops, something went wrong.