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

Goto-transcoder action #236

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions .github/workflows/goto-transcoder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow executes the supported contracts in goto-transcoder

name: Run GOTO Transcoder (ESBMC)

Choose a reason for hiding this comment

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

We need to include a section in our book about the new tool. See Kani example https://model-checking.github.io/verify-rust-std/tools.html

on:
workflow_dispatch:
merge_group:
pull_request:
branches: [ main ]
push:
paths:
- 'library/**'
- '.github/workflows/goto-transcoder.yml'
- 'scripts/run-kani.sh'
- 'scripts/run-goto-transcoder.sh'

defaults:
run:
shell: bash

jobs:
verify-rust-std:
name: Verify contracts with goto-transcoder
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true

# Step 2: Generate contracts programs
- name: Generate contracts
run: ./scripts/run-kani.sh --kani-args --keep-temps --only-codegen

# Step 3: Run goto-transcoder
- name: Run goto-transcoder
run: ./scripts/run-goto-transcoder.sh
49 changes: 49 additions & 0 deletions scripts/run-goto-transcoder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -e

##############
# PARAMETERS #
##############
contract_folder=target/kani_verify_std/target/x86_64-unknown-linux-gnu/debug/deps

Choose a reason for hiding this comment

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

nit... can you pass this as an argument to Kani script and the goto-transcoder script instead of relying here on the location where Kani stores their temporary files?

supported_regex=checked_unchecked.*.out

Choose a reason for hiding this comment

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

Can you also make this an argument so users can easily try out their new harnesses.

unsupported_regex=neg

goto_transcoder_git=https://github.com/rafaelsamenezes/goto-transcoder
esbmc_url=https://github.com/esbmc/esbmc/releases/download/nightly-7867f5e5595b9e181cd36eb9155d1905f87ad241/esbmc-linux.zip

##########
# SCRIPT #
##########

echo "Checking contracts with goto-transcoder"

if [ ! -d "goto-transcoder" ]; then

Choose a reason for hiding this comment

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

can you please add this folder to the git ignore file?

echo "goto-transcoder not found. Downloading..."
git clone $goto_transcoder_git
cd goto-transcoder
wget $esbmc_url
unzip esbmc-linux.zip
chmod +x ./linux-release/bin/esbmc
cd ..
fi

ls $contract_folder | grep "$supported_regex" | grep -v .symtab.out > ./goto-transcoder/_contracts.txt

cd goto-transcoder
while IFS= read -r line; do
contract=`echo "$line" | awk '{match($0, /(_RNv.*).out/, arr); print arr[1]}'`

Choose a reason for hiding this comment

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

can you document what this is doing please?

echo "Processing: $contract"
if [[ -z "$contract" ]]; then
continue
fi
if echo "$contract" | grep -q "$unsupported_regex"; then
continue
fi
echo "Running: goto-transcoder $contract $contract_folder/$line $contract.esbmc.goto"
cargo run cbmc2esbmc $contract ../$contract_folder/$line $contract.esbmc.goto

Choose a reason for hiding this comment

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

does your Cargo.toml file define a workspace? Can you please make sure that running this command won't try to modify this repository root Cargo.toml? Thanks!

./linux-release/bin/esbmc --binary $contract.esbmc.goto
done < "_contracts.txt"

rm "_contracts.txt"
cd ..
Loading