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

feat: solvers package #302

Merged
merged 28 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e56db6a
add packages/solvers
karmacoma-eth Jun 3, 2024
151a205
iterate solvers-publish.yml
karmacoma-eth Jun 3, 2024
c364cf4
fix solvers dockerfile
karmacoma-eth Jun 3, 2024
eca6dba
solvers: go back to ubuntu 22.04 for now
karmacoma-eth Jun 3, 2024
b103440
solvers: install cvc5 from release binaries
karmacoma-eth Jun 3, 2024
9baab5a
fix bitwuzla build
karmacoma-eth Jun 4, 2024
ef4354d
trim down solvers image
karmacoma-eth Jun 4, 2024
d709a22
fix gpg error in yices install
karmacoma-eth Jun 4, 2024
794bdb1
move clean up at the end
karmacoma-eth Jun 4, 2024
fd0595f
move software-properties-common around
karmacoma-eth Jun 4, 2024
fe20af6
install yices with homebrew
karmacoma-eth Jun 4, 2024
f091994
sudo make me a sandwich
karmacoma-eth Jun 4, 2024
87aa4b3
set user to root
karmacoma-eth Jun 4, 2024
abe3ef8
fix ninja command
karmacoma-eth Jun 4, 2024
a4666a6
fix boolector command
karmacoma-eth Jun 4, 2024
e2125c4
install yices from release binaries
karmacoma-eth Jun 4, 2024
b29f01a
try builder pattern
karmacoma-eth Jun 4, 2024
9024483
static build of STP with minisat and cryptominisat
karmacoma-eth Jun 4, 2024
edee71b
update
karmacoma-eth Jun 4, 2024
69772e5
clean up image and add a quick start
karmacoma-eth Jun 4, 2024
4b77231
factor versions out
karmacoma-eth Jun 4, 2024
ba0fca5
fix typo
karmacoma-eth Jun 4, 2024
fa55327
clean up workflow
karmacoma-eth Jun 4, 2024
dcb5036
only copy solver binaries
karmacoma-eth Jun 6, 2024
1321fc0
fix Dockerfile
karmacoma-eth Jun 6, 2024
4a8485e
fix bitwuzla build
karmacoma-eth Jun 6, 2024
360427c
don't forget yices-smt2
karmacoma-eth Jun 6, 2024
ed74102
consolidate the COPY commands into a single one to avoid creating too…
karmacoma-eth Jun 6, 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
52 changes: 52 additions & 0 deletions .github/workflows/solvers-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# based on https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token
name: Push solvers package

on:
workflow_dispatch:
push:
branches:
- feat-packages
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is needed until the workflow is merged to main, can't manually dispatch from a branch


env:
IMAGE_NAME: solvers

jobs:
# This pushes the image to GitHub Packages.
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build . --file packages/solvers/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME

# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
85 changes: 85 additions & 0 deletions packages/solvers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM ubuntu:24.04 as builder

# Install necessary packages
RUN apt-get update && apt-get install --no-install-recommends -y \
curl \
git \
build-essential \
wget \
unzip \
autoconf \
libffi-dev \
cmake \
python3 \
python3-pip \
python3-venv \
ninja-build \
software-properties-common \
g++ zlib1g-dev libboost-all-dev flex bison

# Install Z3
COPY --from=ghcr.io/z3prover/z3:ubuntu-20.04-bare-z3-sha-770c51a /usr/bin/z3 /usr/local/bin/z3

# Install STP
COPY --from=msoos/stp /usr/local/bin/stp /usr/local/bin/stp

# Install Yices from the release binaries
WORKDIR /yices
ARG YICES_VERSION=2.6.4
RUN wget https://github.com/SRI-CSL/yices2/releases/download/Yices-${YICES_VERSION}/yices-${YICES_VERSION}-x86_64-pc-linux-gnu.tar.gz -O yices.tar.gz && \
tar -xzvf yices.tar.gz --strip-components=1 && \
mv /yices/bin/* /usr/local/bin/ && \
mv /yices/lib/* /usr/local/lib/ && \
mv /yices/include/* /usr/local/include/ && \
rm -rf /yices

# Install cvc5 from release binaries
WORKDIR /cvc5
ARG CVC5_VERSION=1.1.2
RUN wget https://github.com/cvc5/cvc5/releases/download/cvc5-${CVC5_VERSION}/cvc5-Linux-static.zip -O cvc5-Linux-static.zip && \
unzip cvc5-Linux-static.zip && \
mv cvc5-Linux-static/bin/cvc5 /usr/local/bin/cvc5 && \
chmod +x /usr/local/bin/cvc5 && \
rm -rf /cvc5

# Install Bitwuzla
WORKDIR /bitwuzla
RUN git clone --depth 1 https://github.com/bitwuzla/bitwuzla . && \
python3 -m venv .venv && \
. .venv/bin/activate && \
python3 -m pip install meson && \
./configure.py && \
cd build && \
ninja install && \
rm -rf /bitwuzla

# Install Boolector
WORKDIR /boolector
RUN git clone --depth 1 https://github.com/boolector/boolector . && \
./contrib/setup-lingeling.sh && \
./contrib/setup-btor2tools.sh && \
./configure.sh && \
cd build && \
make && \
mv /boolector/build/bin/* /usr/local/bin/ && \
rm -rf /boolector

# Create the final image
FROM ubuntu:24.04
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:
Is there a specific reason for using different Ubuntu versions between the final image and the builder?

If there is no specific reason, it would be better to unify them. This can help streamline the build process and reduce potential compatibility issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't able to build yices on 24.04, but since we moved to binary releases it should be fine. I'll unify on 24.04


# Copy installed files from builder

COPY --from=builder \
/usr/local/bin/z3 \
/usr/local/bin/stp \
/usr/local/bin/cvc5 \
/usr/local/bin/yices \
/usr/local/bin/yices-smt2 \
/usr/local/bin/bitwuzla \
/usr/local/bin/boolector \
/usr/local/bin/


# Set the default command for the container
WORKDIR /workspace
CMD ["/bin/bash"]
50 changes: 50 additions & 0 deletions packages/solvers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# solvers package

A minimalist Docker image containing high-performance SMT solvers.

## Quick start

```sh
# Step 1: Pull the image
docker pull ghcr.io/a16z/solvers:latest

# Step 2: Tag the image with a shorter name
docker tag ghcr.io/a16z/solvers:latest solvers

# Step 3: Run the container using the shorter name,
for solver in bitwuzla boolector cvc5 stp yices z3 ; do \
echo --- $solver && \
docker run --rm solvers $solver --version ; \
done

# Step 4: create an example smt2 file:
cat << EOF > checkSanity.smt2
(set-logic QF_BV)
(assert (= (bvsdiv (_ bv3 2) (_ bv2 2)) (_ bv0 2)))
(check-sat)
(exit)
EOF

# Step 5: invoke each solver on the file
# (`-v .:/workspace` mounts the current working directory under /workspace on the container, making the files available there)
for solver in bitwuzla boolector cvc5 stp yices-smt2 z3 ; do \
echo -n "$solver: " && \
docker run --rm -v .:/workspace solvers $solver checkSanity.smt2 ; \
done
```

## Available solvers

| Solver | Version | URL | Notes
| ------ | ------- | --- | ----- |
| Bitwuzla | 0.5.0-dev-main@50ce452 | [bitwuzla/bitwuzla](https://github.com/bitwuzla/bitwuzla) | Built from source
| Boolector | 3.2.3 | [boolector/boolector](https://github.com/boolector/boolector) | Built from source
| CVC5 | 1.1.2 | [cvc5/cvc5](https://github.com/cvc5/cvc5) | Installed from Github release binaries
| STP | 2.3.3 | [stp/stp](https://github.com/stp/stp) | Provides a great Dockerfile that shows how to do a static build. We just copy the binary from the `msoos/stp` image since releases aren't too frequent. |
| Yices | 2.6.4 | [SRI-CSL/yices2](https://github.com/SRI-CSL/yices2) | Installed from Github release binaries
| Z3 | 4.13.1 | [Z3Prover/z3](https://github.com/Z3Prover/z3) | Includes a [Dockerfile](https://github.com/Z3Prover/z3/blob/master/docker/ubuntu-20-04.Dockerfile) and a package but no `latest` tag |


## Credit

Based on [EmperorOrokuSaki/solvers](https://github.com/EmperorOrokuSaki/solvers)
Loading