From fb790e4fb346253b3389a18e078da81b30ea51f0 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Mon, 13 Apr 2020 18:04:16 +0200 Subject: [PATCH 1/6] libkexec/klab-zip: rename to klab-compress Since we might want to change the compression method. --- README.md | 2 +- libexec/{klab-zip => klab-compress} | 0 libexec/klab-help | 2 +- libexec/klab-prove-all | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename libexec/{klab-zip => klab-compress} (100%) diff --git a/README.md b/README.md index 9a722dcb..22c39f9a 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Remember, you must turn on the **d**ebug cells view to see these (above). - `klab status ` - Shows whether a proof has been run, and whether it was accepted or rejected. - `klab status-js ` - Shows the behaviour tree for an executed proof. - `klab fetch ` - Fetches the execution trace of a proof object at the url, preparing it for local debugging. -- `klab zip ` - zips up an execution trace so you can share it with a friend (or enemy). +- `klab compress ` - compresses an execution trace so you can share it with a friend (or enemy). - `klab storage ` - Guesses what the storage layout of a given contract is - `klab report` - Generates a html report of the current project state in `out/report/index.html`. - `klab help` - Generates this view diff --git a/libexec/klab-zip b/libexec/klab-compress similarity index 100% rename from libexec/klab-zip rename to libexec/klab-compress diff --git a/libexec/klab-help b/libexec/klab-help index c10c7d86..038fc67b 100755 --- a/libexec/klab-help +++ b/libexec/klab-help @@ -26,7 +26,7 @@ Commands: - klab fetch - Fetches the execution trace of a proof object at the url, preparing it for local debugging. -- klab zip - zips up an execution trace so you can share it with a friend (or enemy). +- klab compress - zips up an execution trace so you can share it with a friend (or enemy). - klab storage - Guesses what the storage layout of a given contract is diff --git a/libexec/klab-prove-all b/libexec/klab-prove-all index dd1c6286..4e059367 100755 --- a/libexec/klab-prove-all +++ b/libexec/klab-prove-all @@ -72,7 +72,7 @@ export -f report savelogs() { local hash=$1 - klab zip "$hash" > /dev/null + klab compress "$hash" > /dev/null cp "$KLAB_OUT/log/${hash}.zip" "$KLAB_REPORT_NAME_DIR" cp "$KLAB_OUT/log/${hash}.log" "$KLAB_REPORT_NAME_DIR" cp "$KLAB_OUT/log/${hash}.err.log" "$KLAB_REPORT_NAME_DIR" From cdbcbd5216a0e9312b8c89c17b35514c9e55ceb1 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Mon, 13 Apr 2020 18:05:37 +0200 Subject: [PATCH 2/6] libexec/klab-compress: using POSIX-compliant args See find's manual. --- libexec/klab-compress | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/klab-compress b/libexec/klab-compress index d0c25f4e..463124e1 100755 --- a/libexec/klab-compress +++ b/libexec/klab-compress @@ -35,8 +35,8 @@ zip -r "$KLAB_OUT/log/$spec_hash.zip" config.json cd $KLAB_OUT find . \ - \( -wholename "*$spec_hash*" -or -wholename "*$spec_name*" \) \ - -and ! -wholename "*/log/*.zip" \ + \( -wholename "*$spec_hash*" -o -wholename "*$spec_name*" \) \ + -a ! -wholename "*/log/*.zip" \ -exec zip "./log/$spec_hash.zip" {} + zip -r "log/$spec_hash.zip" \ From 96ef42dbf172ad1a3a5b7a20466dd5ae4ab6790b Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Mon, 13 Apr 2020 18:24:44 +0200 Subject: [PATCH 3/6] libexec/klab-compress: use zstd Wins at benchmarks. --- libexec/klab-compress | 19 +++++++++---------- libexec/klab-fetch | 2 +- shell.nix | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libexec/klab-compress b/libexec/klab-compress index 463124e1..7809ce2b 100755 --- a/libexec/klab-compress +++ b/libexec/klab-compress @@ -31,15 +31,14 @@ if [ ! -d "$KLAB_OUT/log" ]; then mkdir -p "$KLAB_OUT/log" fi -zip -r "$KLAB_OUT/log/$spec_hash.zip" config.json - cd $KLAB_OUT find . \ - \( -wholename "*$spec_hash*" -o -wholename "*$spec_name*" \) \ - -a ! -wholename "*/log/*.zip" \ - -exec zip "./log/$spec_hash.zip" {} + - -zip -r "log/$spec_hash.zip" \ - "prelude.smt2" \ - "rules.k" \ - "bin_runtime.k" + \( -name "*$spec_hash*" \ + -o -name "*$spec_name*" \ + -o -name config.tmp.json \ + -o -name prelude.smt2 \ + -o -name rules.k \ + -o -name bin_runtime.k \) \ + -a \! -name "*.tar" \ + -a \! -name "*.zip" \ + -exec tar --create --zstd --file "./log/$spec_hash.tar" {} + diff --git a/libexec/klab-fetch b/libexec/klab-fetch index a688dd20..8e0ff171 100755 --- a/libexec/klab-fetch +++ b/libexec/klab-fetch @@ -11,6 +11,6 @@ mkdir -p "$KLAB_OUT"/log wget -c "$url" -P "$KLAB_OUT"/log/ unzip -qu "$KLAB_OUT/log/${url##*/}" -d "$KLAB_OUT" # log the proof hash -hash=$(basename "$url" '.zip') +hash=$(basename "$url" '.tar') echo $hash > $KLAB_OUT/HEAD echo "Focusing on: $hash" diff --git a/shell.nix b/shell.nix index 557de313..90085688 100644 --- a/shell.nix +++ b/shell.nix @@ -34,10 +34,9 @@ pkgs.stdenv.mkDerivation { python python3 time - unzip wget - zip z3 + zstd ]; shellHook = '' export PATH=${toString ./node_modules/.bin}:${toString ./bin}:$PATH From 50dd2aee664c14a59f3fe3a2b6f112cd2133eb96 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Mon, 13 Apr 2020 19:24:55 +0200 Subject: [PATCH 4/6] *: replace occurrencies of zip with tar --- libexec/klab-fetch | 2 +- libexec/klab-help | 2 +- libexec/klab-prove-all | 2 +- libexec/klab-report | 14 +++++++------- resources/report.css | 2 +- resources/report.scss | 2 +- resources/zsh/_klab | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libexec/klab-fetch b/libexec/klab-fetch index 8e0ff171..44eee179 100755 --- a/libexec/klab-fetch +++ b/libexec/klab-fetch @@ -9,7 +9,7 @@ url=$1 mkdir -p "$KLAB_OUT"/log wget -c "$url" -P "$KLAB_OUT"/log/ -unzip -qu "$KLAB_OUT/log/${url##*/}" -d "$KLAB_OUT" +tar xf "$KLAB_OUT/log/${url##*/}" -C "$KLAB_OUT" # log the proof hash hash=$(basename "$url" '.tar') echo $hash > $KLAB_OUT/HEAD diff --git a/libexec/klab-help b/libexec/klab-help index 038fc67b..41d786b8 100755 --- a/libexec/klab-help +++ b/libexec/klab-help @@ -26,7 +26,7 @@ Commands: - klab fetch - Fetches the execution trace of a proof object at the url, preparing it for local debugging. -- klab compress - zips up an execution trace so you can share it with a friend (or enemy). +- klab compress - compresses an execution trace so you can share it with a friend (or enemy). - klab storage - Guesses what the storage layout of a given contract is diff --git a/libexec/klab-prove-all b/libexec/klab-prove-all index 4e059367..f36f0fb2 100755 --- a/libexec/klab-prove-all +++ b/libexec/klab-prove-all @@ -73,7 +73,7 @@ export -f report savelogs() { local hash=$1 klab compress "$hash" > /dev/null - cp "$KLAB_OUT/log/${hash}.zip" "$KLAB_REPORT_NAME_DIR" + cp "$KLAB_OUT/log/${hash}.tar" "$KLAB_REPORT_NAME_DIR" cp "$KLAB_OUT/log/${hash}.log" "$KLAB_REPORT_NAME_DIR" cp "$KLAB_OUT/log/${hash}.err.log" "$KLAB_REPORT_NAME_DIR" } diff --git a/libexec/klab-report b/libexec/klab-report index d6506460..11bbd32b 100755 --- a/libexec/klab-report +++ b/libexec/klab-report @@ -152,13 +152,13 @@ const getBadges = (cases, act) => { const outPath = path.join(KLAB_OUT, "log", s.proofid + ".log"); const errPath = path.join(KLAB_OUT, "log", s.proofid + ".err.log"); - const zipPath = path.join(KLAB_OUT, "log", s.proofid + ".zip"); + const tarballPath = path.join(KLAB_OUT, "log", s.proofid + ".tar"); const gasPath = path.join(KLAB_OUT, "gas", s.proofid + ".all.json"); const lemmaPath = path.join(KLAB_OUT, "log", s.proofid + "_lemma_stats.json"); const hasOut = testPath(outPath) && read(outPath).trim() !== ""; const hasErr = testPath(errPath) && read(errPath).trim() !== ""; - const hasZip = testPath(zipPath); + const hasTarball = testPath(tarballPath); const hasGas = testPath(gasPath); const lemma_stats = testPath(lemmaPath) && JSON.parse(read(lemmaPath)) || {}; @@ -177,11 +177,11 @@ const getBadges = (cases, act) => { proof_info.push(td(badge(c.suffix, ((rejected || aborted) ? `${s.status} [${s.exit}]` : s.status)))) - let zip = ""; - if(finished && hasZip) { - zip = tr(`${h(['input', `class="autoselect" type="text" value="klab fetch https://${config.host}/${config.name}/${s.proofid+'.zip'}" onfocus="this.select()"`])("")}`) + let tarball = ""; + if(finished && hasTarball) { + tarball = tr(`${h(['input', `class="autoselect" type="text" value="klab fetch https://${config.host}/${config.name}/${s.proofid+'.tar'}" onfocus="this.select()"`])("")}`) } else if (rejected || aborted) { - zip = tr(`${h(['input', `class="autoselect" type="text" value="No log archive found"`])("")}`) + tarball = tr(`${h(['input', `class="autoselect" type="text" value="No log archive found"`])("")}`) } let lemmas = "" @@ -191,7 +191,7 @@ const getBadges = (cases, act) => { ]) } - return h(["tr", `id="${s.spec}" class="${s.status}"`])(proof_info) + zip + lemmas + return h(["tr", `id="${s.spec}" class="${s.status}"`])(proof_info) + tarball + lemmas }) .join('\n') return { diff --git a/resources/report.css b/resources/report.css index 24c153d9..8476dff6 100644 --- a/resources/report.css +++ b/resources/report.css @@ -22,7 +22,7 @@ a { .actstatus table { border-spacing: 0px; width: 100%; } - .actstatus table td.zipselect { + .actstatus table td.tarballselect { padding-bottom: 1em; } .actstatus table td:last-child { text-align: right; } diff --git a/resources/report.scss b/resources/report.scss index fc3bc9e9..c1566fbc 100644 --- a/resources/report.scss +++ b/resources/report.scss @@ -31,7 +31,7 @@ a { table { border-spacing: 0px; width: 100%; - td.zipselect { + td.tarballselect { padding-bottom: 1em; } td { diff --git a/resources/zsh/_klab b/resources/zsh/_klab index ddba65ef..44eb6d9c 100644 --- a/resources/zsh/_klab +++ b/resources/zsh/_klab @@ -19,7 +19,7 @@ _klab() { "--evm[reduce a k term to only include evm relevant information]" _values -C 'proofname' $(ls ${KLAB_OUT:-out}/meta/{name,data}/) ;; - focus|do-prove|get-gas|solve-gas|status|zip) + focus|do-prove|get-gas|solve-gas|status|compress) _values -C 'proofname' $(ls ${KLAB_OUT:-out}/meta/{name,data}/) ;; debug) @@ -56,7 +56,7 @@ _klab() { "report:generate a report" "solve-gas:generate a simple gas kast expression based on the raw gas" "status:display the proofstatus" - "zip:bundle a proof to a zip file" + "compress:bundle a proof into a compressed tarball" ) _describe -t commands 'klab' subcommands fi From 156918a58605639e70f5ca9f1281680ac33d194a Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Wed, 15 Apr 2020 16:46:54 +0200 Subject: [PATCH 5/6] libexec/klab-fetch: handle both zip and tar Or actually, anything tar can handle. --- libexec/klab-fetch | 18 ++++++++++++++---- shell.nix | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libexec/klab-fetch b/libexec/klab-fetch index 44eee179..c00ef821 100755 --- a/libexec/klab-fetch +++ b/libexec/klab-fetch @@ -6,11 +6,21 @@ if [ -z "$KLAB_OUT" ]; then fi url=$1 +filename=${url##*/} mkdir -p "$KLAB_OUT"/log wget -c "$url" -P "$KLAB_OUT"/log/ -tar xf "$KLAB_OUT/log/${url##*/}" -C "$KLAB_OUT" -# log the proof hash -hash=$(basename "$url" '.tar') -echo $hash > $KLAB_OUT/HEAD + +case $url in + *.zip) + unzip -qu "$KLAB_OUT/log/$filename" -d "$KLAB_OUT" + ;; + *) + tar xf "$KLAB_OUT/log/$filename" -C "$KLAB_OUT" + ;; +esac + +# remove extension +hash=${filename%%.*} echo "Focusing on: $hash" +echo "$hash" > $KLAB_OUT/HEAD diff --git a/shell.nix b/shell.nix index 90085688..c68e2a6c 100644 --- a/shell.nix +++ b/shell.nix @@ -34,6 +34,7 @@ pkgs.stdenv.mkDerivation { python python3 time + unzip wget z3 zstd From 98bb5ada58ce1da6e8bbd7cdba449903f52c1a0c Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Wed, 15 Apr 2020 16:49:20 +0200 Subject: [PATCH 6/6] libexec/klab-fetch: print usage on missing arg --- libexec/klab-fetch | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/klab-fetch b/libexec/klab-fetch index c00ef821..43afe77f 100755 --- a/libexec/klab-fetch +++ b/libexec/klab-fetch @@ -5,6 +5,7 @@ if [ -z "$KLAB_OUT" ]; then KLAB_OUT=out fi +[[ $# -eq 1 ]] || (echo >&2 "Usage: klab fetch \$URL" && exit 1) url=$1 filename=${url##*/}