Skip to content

Commit

Permalink
Merge branch 'rampup' into feat/add-o1js-stubs-rampup
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMinkov authored Jan 9, 2024
2 parents 94df4c7 + 8e71923 commit 9e7a789
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 16 deletions.
6 changes: 5 additions & 1 deletion buildkite/scripts/export-git-env-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ export MINA_DEB_CODENAME=${MINA_DEB_CODENAME:=bullseye}


if [ "${BUILDKITE_REPO}" != "${MINA_REPO}" ]; then
# Abort if `BUILDKITE_REPO` doesn't have the expected format
echo ${BUILDKITE_REPO} | grep -P '^.*github.com[:\/](.*)\.git$' > /dev/null || \
(echo "BUILDKITE_REPO does not have the expected format" && false)

# We don't want to allow some operations on fork repository which should be done on main repo only.
# Publish to docker hub or publish to unstable debian channel should be exclusive to main repo as it can override
# packages from main repo (by using the same commit and the same branch from forked repository)

# We don't want to use tags (as this can replace our dockers/debian packages). Instead we are using repo name
# For example: for given repo 'https://github.com/dkijania/mina.git' we convert it to 'dkijania_mina'
export GITTAG=1.0.0$(echo ${BUILDKITE_REPO} | sed -e "s/https:\/\/github.com\///g" | sed -e "s/.git//g" | sed -e "s/\//-/g")
export GITTAG=1.0.0$(echo ${BUILDKITE_REPO} | sed -e 's/^.*github.com[:\/]\(.*\)\.git$/\1/' -e 's/\//-/')
export THIS_COMMIT_TAG=""
RELEASE=unstable

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE zkapp_account_precondition
ADD CONSTRAINT zkapp_account_precondition_unique UNIQUE(balance_id, receipt_chain_hash, delegate_id, state_id, action_state_id, proved_state, is_new, nonce_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

set -e

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

ARCHIVE_DB=$1
BODY_DATA_BCK=zkapp_update_body_data_table.bck
PRECONDITION_DATA_BCK=zkapp_precondition_table.bck
PRECONDITION_DATA_TMP=zkapp_precondition_table.tmp
PRECONDITION_UPDATE_SCRIPT=zkapp_precondition_script.sql
BODY_UPDATE_SCRIPT=zkapp_update_body_script.sql

echo "This Shell script will produce two SQL scripts that will remove duplicated zkApp account preconditions rows in the archive DB" "$ARCHIVE_DB"

rm -f $BODY_DATA_BCK
rm -f $PRECONDITION_DATA_BCK
rm -f $PRECONDITION_DATA_TMP
rm -f $PRECONDITION_UPDATE_SCRIPT
rm -f $BODY_UPDATE_SCRIPT

ALL_TABLES="balance_id,receipt_chain_hash,delegate_id,state_id,action_state_id,proved_state, is_new, nonce_id"

echo "Creating backup of zkapp_account_preconditions table " "$PRECONDITION_DATA_BCK"

echo "SELECT * FROM zkapp_account_precondition" | \
psql -U postgres --csv -q -t "$ARCHIVE_DB" > $PRECONDITION_DATA_BCK

echo "Creating backup of zkapp_update_body table " "$BODY_DATA_BCK"

echo "SELECT * FROM zkapp_account_update_body" | \
psql -U postgres --csv -q -t "$ARCHIVE_DB" > $BODY_DATA_BCK


echo "Creating temporary file of zkapp_account_preconditions table with duplicated rows" "$PRECONDITION_DATA_TMP"

echo "SELECT MIN(id) as id, $ALL_TABLES, MAX(id) as duplicated_id \
FROM zkapp_account_precondition \
GROUP BY $ALL_TABLES \
HAVING COUNT(*) > 1" | \
psql -U postgres --csv -q -t "$ARCHIVE_DB" > $PRECONDITION_DATA_TMP


if [[ $(wc -l < $PRECONDITION_DATA_TMP) -gt 0 ]]; then

echo "Creating SQL scripts for removing duplications" "$PRECONDITION_UPDATE_SCRIPT" "and updating references" "$BODY_UPDATE_SCRIPT"

cat $PRECONDITION_DATA_TMP | while IFS= read -r line
do
ID_TO_REPLACE=$(echo "$line" | awk -F , '{print $1}');
ID_TO_REMOVE=$(echo "$line" | awk -F , '{print $10}');
echo -n .
echo "$ID_TO_REPLACE $ID_TO_REMOVE" | awk '{print "UPDATE zkapp_account_update_body SET zkapp_account_precondition_id = " $1 " WHERE zkapp_account_precondition_id =" $2 ";"}' >> $BODY_UPDATE_SCRIPT
echo "$ID_TO_REMOVE" | awk '{print "DELETE FROM zkapp_account_precondition WHERE id=" $1 ";"}' >> $PRECONDITION_UPDATE_SCRIPT
done

echo
echo "SQL scripts are ready: $PRECONDITION_UPDATE_SCRIPT, $BODY_UPDATE_SCRIPT !"
else
echo
echo "No duplicated rows found. Database state is correct !"
fi
3 changes: 3 additions & 0 deletions src/app/archive/add_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE INDEX idx_zkapp_field_array_element_ids ON zkapp_field_array(element_ids);

CREATE INDEX idx_zkapp_events_element_ids ON zkapp_events(element_ids);
2 changes: 1 addition & 1 deletion src/app/archive/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name archive_lib)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/archive/lib/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name graphql_query)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
5 changes: 5 additions & 0 deletions src/app/archive/zkapp_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ CREATE TABLE zkapp_field_array
, element_ids int[] NOT NULL
);

CREATE INDEX idx_zkapp_field_array_element_ids ON zkapp_field_array(element_ids);

/* Fixed-width arrays of algebraic fields, given as id's from
zkapp_field
Expand Down Expand Up @@ -81,6 +83,8 @@ CREATE TABLE zkapp_events
, element_ids int[] NOT NULL
);

CREATE INDEX idx_zkapp_events_element_ids ON zkapp_events(element_ids);

/* field elements derived from verification keys */
CREATE TABLE zkapp_verification_key_hashes
( id serial PRIMARY KEY
Expand Down Expand Up @@ -162,6 +166,7 @@ CREATE TABLE zkapp_account_precondition
, action_state_id int REFERENCES zkapp_field(id)
, proved_state boolean
, is_new boolean
, UNIQUE(balance_id, receipt_chain_hash, delegate_id, state_id, action_state_id, proved_state, is_new, nonce_id)
);

CREATE TABLE zkapp_accounts
Expand Down
2 changes: 1 addition & 1 deletion src/app/benchmarks/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 3.3)
(name benchmarks)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/cli/src/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 3.3)
(name graphql)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/dump_blocks/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name dump_blocks)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/logproc/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name logproc)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/reformat/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 3.2)
(name reformat)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/rosetta/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 3.3)
(name rosetta)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/runtime_genesis_ledger/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name runtime_genesis_ledger)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/app/zkapp_test_transaction/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name zkapp_test_transaction)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/dune-project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(lang dune 3.3)
(implicit_transitive_deps false)
(implicit_transitive_deps true)

(package (name allocation_functor))
(package (name archive_blocks))
Expand Down
3 changes: 1 addition & 2 deletions src/lib/pickles/step.ml
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ struct
Option.map
~f:(Scalar_challenge.map ~f:Challenge.Constant.of_tock_field)
(O.joint_combiner_chal o)
; feature_flags =
t.statement.proof_state.deferred_values.plonk.feature_flags
; feature_flags = Plonk_types.Features.none_bool
}
in
let xi = scalar_chal O.v in
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transition_frontier/dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 2.8)
(name transition_frontier)
(implicit_transitive_deps false)
(implicit_transitive_deps true)
2 changes: 1 addition & 1 deletion src/nonconsensus/dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 2.8)
(implicit_transitive_deps false)
(implicit_transitive_deps true)

0 comments on commit 9e7a789

Please sign in to comment.