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

Adopt Grackle in gokv tutorial #150

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
799b72d
setup perennial for nix development
mjschwenne Nov 12, 2024
d0f74e1
fix nix setup
mjschwenne Nov 12, 2024
278c1ed
Start working on update-grackle.sh
mjschwenne Nov 12, 2024
ed01ac1
Finished (but untested) update-grackle.sh
mjschwenne Nov 12, 2024
3dc6da7
Update flake to include protoc
mjschwenne Nov 12, 2024
fbebaab
Begin grackle integration
mjschwenne Nov 13, 2024
5cdcc20
begin integration of kvservice
mjschwenne Nov 13, 2024
137f830
Add Matt Schwennesen to email list
mjschwenne Nov 13, 2024
6d2ac1b
Merge branch 'master' into grackle
mjschwenne Nov 13, 2024
f6d68b1
finish integrating kvservice/proof.v
mjschwenne Nov 13, 2024
4540441
Merge branch 'master' into grackle
mjschwenne Nov 19, 2024
3722f47
Merge branch 'master' to get kvservice proof
mjschwenne Nov 25, 2024
c63b3a9
begin grackle integration of tutorial/kvservice/full_proof.v
mjschwenne Nov 25, 2024
93a1f6d
fix typo in tutorial/kvservice/full_proof.v
mjschwenne Nov 27, 2024
93e83fe
Merge branch 'master' into grackle
mjschwenne Dec 3, 2024
bf2fb41
update grackle and goose
mjschwenne Dec 3, 2024
5bc8428
update update-grackle with flake integration
mjschwenne Dec 3, 2024
19fa0ef
setup grackle checking for perennial
mjschwenne Dec 3, 2024
de4422e
draft spec for wp_ReadSlice
mjschwenne Dec 4, 2024
b79121e
add encode fixpoint
mjschwenne Dec 4, 2024
f3cecb1
begin working on ReadSlice loop proof
mjschwenne Dec 5, 2024
0c7b6d7
More work on ReadSlice
mjschwenne Dec 5, 2024
210b349
More work on finishing ReadSlice proof
mjschwenne Dec 5, 2024
e83d9c1
Finish ReadSlice proof
mjschwenne Dec 6, 2024
5f4940f
Remove length xs < 2^64 precondition
tchajed Dec 11, 2024
b3d2eb5
update to use value-based grackle, merge changes
mjschwenne Jan 9, 2025
ab7d68f
remove commented marshaling code
mjschwenne Jan 13, 2025
e9530c4
Merge branch 'master' into grackle
mjschwenne Jan 14, 2025
92ed2ba
Mark auto-generated files for GitHub PR review
tchajed Jan 14, 2025
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
external/Goose/** linguist-generated
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ jobs:
- name: check that Goosed files are clean
run: etc/ci-goose-check.py

check-grackle:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install protoc
run: sudo apt-get install protobuf-compiler -y
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Check Grackle
run: |
./etc/ci-grackle-check.py
git diff --exit-code

python:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ __pycache__

# Compiled code supplement
/peony-code.zip

# direnv
.direnv
56 changes: 56 additions & 0 deletions etc/ci-grackle-check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3

import shutil
import subprocess as sp
from dataclasses import dataclass


@dataclass
class Proj:
name: str
repo: str
commit: str

def path(self) -> str:
return f"/tmp/{self.name}"


projs = {
"gokv": Proj("gokv", "https://github.com/mit-pdos/gokv", "main"),
}


def checkout(proj: Proj):
print(f"Checking out {proj.name}")
path = proj.path()
shared_args = {"check": True, "cwd": path}

try:
p = sp.run(
["git", "remote", "get-url", "origin"],
text=True,
capture_output=True,
**shared_args,
)
assert p.stdout.strip() == proj.repo
sp.run(["git", "reset", "--hard"], **shared_args)
sp.run(["git", "pull"], **shared_args)
except (FileNotFoundError, sp.CalledProcessError, AssertionError):
shutil.rmtree(path, ignore_errors=True)
sp.run(["git", "clone", proj.repo, path], check=True)

sp.run(["git", "checkout", proj.commit], **shared_args)


for proj in projs.values():
checkout(proj)

print("\nRunning Grackle")
sp.run(
[
"etc/update-grackle.sh",
"--gokv",
projs["gokv"].path(),
],
check=True,
)
10 changes: 9 additions & 1 deletion etc/update-goose.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3

import os
from os import path
import subprocess
from os import path


def run_command(args, dry_run=False, verbose=False):
Expand Down Expand Up @@ -281,10 +281,18 @@ def run_goose(src_path, *pkgs):
"./vrsm/apps/closed",
"./tutorial", # atomic commit
"./tutorial/objectstore/dir",
"./tutorial/objectstore/dir/chunkhandle_gk",
"./tutorial/objectstore/dir/finishwrite_gk",
"./tutorial/objectstore/dir/recordchunk_gk",
"./tutorial/objectstore/chunk",
"./tutorial/objectstore/chunk/writechunk_gk",
"./tutorial/objectstore/client",
"./tutorial/lockservice",
"./tutorial/lockservice/lockrequest_gk",
"./tutorial/kvservice",
"./tutorial/kvservice/conditionalput_gk",
"./tutorial/kvservice/get_gk",
"./tutorial/kvservice/put_gk",
"./tutorial/basics",
"./tutorial/queue",
"./map_marshal",
Expand Down
95 changes: 95 additions & 0 deletions etc/update-grackle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

if [[ -z "$IN_NIX_SHELL" ]]; then
# Not in nix shell, use the default go installs
GRACKLE="go run github.com/mjschwenne/grackle/cmd/grackle@latest"
else
# In a nix shell, expect grackle to be on the PATH and use that
GRACKLE="grackle"
fi

compile_grackle() {
CWD=$(pwd)
cd "$1" || return
go install ./cmd/grackle
cd "$CWD" || exit
}

# Computes the coq logical name by
#
# - Replacing "." with "-"
# - Replacing "-" with "_"
# - Replacing "/" with "."
#
# This mirrors grackle/internal/util/util.go :: CleanCoqName function
coq_logical_name() {
echo "$1" | sed -E -e "s/\./-/g" -e "s/-/_/g" -e "s/\//\./g"
}

# Run grackle on the input go package.
#
# We will assume that:
# 1. The proto file is in the directory $2/$1
# 2. We only want to output coq code
# 3. The coq code should be output into "src/program_proof/$1"
# 4. The desired coq package matches the directory structure
#
# Parameters
# - $1 : Name of the go package inside its repo
# - $2 : Path to the root of the go repo. Go package to translate should be at "$2/$1"
# - $3 : Prefix to compute the go package name, "$3/$1"
run_grackle() {
$GRACKLE --coq-logical-path "Perennial.program_proof.$(coq_logical_name $1)" --coq-physical-path "src/program_proof/$1" --go-package "$3/$1" "$(realpath "$2/$1")"
}

# Generate Coq files from gokv repo.
#
# Parameters
# - $1 : Path to the gokv repo.
grackle_gokv() {
gokv_packages=(
"tutorial/kvservice"
"tutorial/lockservice"
"tutorial/objectstore/chunk"
"tutorial/objectstore/dir"
)

for gopkg in "${gokv_packages[@]}"; do
run_grackle "$gopkg" "$1" "github.com/mit-pdos/gokv"
done
}

ARGS=$(getopt -o "c:g:h" --long "compile-grackle:,gokv:,help" -- "$@")

eval set -- "$ARGS"
while [ $# -ge 1 ]; do
case "$1" in
-c | --compile-grackle)
compile_grackle "$2"
shift
;;
-g | --gokv)
grackle_gokv "$2"
shift
;;
-h | --help)
cat <<EOF
usage: update-grackle.sh [--compile-grackle <grackle repo> | -c <grackle repo>]
[--gokv | -g] [--help | -h]

Calls grackle on all gokv go modules known to have proto files for grackle usage, generating coq proofs.

--compile-grackle [-c] : Takes the path to the grackle repository, recompiles and installs grackle

--gokv [-g] : Regenerate Coq proofs for the gokv project, takes path to gokv as argument
EOF
shift
exit 0
;;
--)
shift
break
;;
esac
shift
done
Loading
Loading