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

Generate script to patch receipt chain hashes and last VRF output #14419

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions scripts/migrate-receipt-chain-hashes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

if [ ! $# -eq 1 ] ; then
echo "Usage" $0 archive-db
exit 0
fi

ARCHIVE_DB=$1
HASHES_FILE=hashes_file.tmp
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't those be a parameters ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Made them optional command-line args.

UPDATE_SCRIPT=hashes_update.sql

rm -f $HASHES_FILE
rm -f $UPDATE_SCRIPT

echo "select id,receipt_chain_hash from zkapp_account_precondition where receipt_chain_hash is not null;" | \
psql --csv -t -q $ARCHIVE_DB > $HASHES_FILE

for line in `cat $HASHES_FILE`
do (
ID=$(echo $line | awk -F , '{print $1}');
FP=$(echo $line | awk -F , '{print $2}');
B58=$(echo $FP | _build/default/src/app/receipt_chain_hash_to_b58/receipt_chain_hash_to_b58.exe);
echo $ID "'"$B58"'" | awk '{print "UPDATE zkapp_account_precondition SET receipt_chain_hash=" $2 " WHERE id=" $1 ";"}' >> $UPDATE_SCRIPT)
done

echo "Done!"
echo "Now run:" "psql -d" $ARCHIVE_DB "<" $UPDATE_SCRIPT
19 changes: 19 additions & 0 deletions src/app/receipt_chain_hash_to_b58/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(executable
(package receipt_chain_hash_to_b58)
(name receipt_chain_hash_to_b58)
(public_name receipt_chain_hash_to_b58)
(libraries
;; opam libraries
;; local libraries
mina_base
kimchi_backend
kimchi_backend.pasta
kimchi_backend.pasta.basic
pickles
pickles.backend
pickles_types
snark_params
)
(preprocessor_deps ../../config.mlh)
(instrumentation (backend bisect_ppx))
(preprocess (pps ppx_mina ppx_version)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let () =
let s = Stdlib.read_line () in
let fp = Kimchi_backend.Pasta.Basic.Fp.of_string s in
let receipt_chain_hash : Mina_base.Receipt.Chain_hash.t = fp in
Format.printf "%s@." (Mina_base.Receipt.Chain_hash.to_base58_check receipt_chain_hash)
1 change: 1 addition & 0 deletions src/dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
(package (name random_oracle_input))
(package (name random_oracle))
(package (name rc_pool))
(package (name receipt_chain_hash_to_b58))
(package (name replayer))
(package (name rfc3339_time))
(package (name rocksdb))
Expand Down