44TOTAL_BLOCKS=25
55
66# go to root of mina repo
7- cd $( dirname -- " ${BASH_SOURCE[0]} " ) /..
7+ cd " $( dirname -- " ${BASH_SOURCE[0]} " ) " /..
88
99# Prepare the database
1010sudo -u postgres dropdb archive || true # fails when db doesn't exist which is fine
@@ -20,13 +20,15 @@ psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';"
2020 -tf 1 --override-slot-time 30000 \
2121 -zt -vt -lp &
2222
23+ LOCAL_NETWORK_DATA_FOLDER=" ${HOME} " /.mina-network/mina-local-network-2-1-1
24+
2325trap " pkill -f mina-local-network" EXIT
2426
2527# stop mina-local-network once enough blocks have been produced
2628while true ; do
2729 sleep 10s
2830 # psql outputs " " until there are blocks in the db, the +0 defaults that to 0
29- BLOCKS=" $(( $(psql - U postgres archive - t - c "select MAX(global_slot_since_genesis ) from blocks" 2 > / dev/ null) + 0 )) "
31+ BLOCKS=" $(( $(psql - U postgres archive - t - c "select MAX(height ) from blocks" 2 > / dev/ null) + 0 )) "
3032 echo Generated $BLOCKS /$TOTAL_BLOCKS blocks
3133 if [ " $(( BLOCKS+ 0 )) " -ge $TOTAL_BLOCKS ] ; then
3234 pkill -f mina-local-network
3739echo Converting canonical blocks
3840source ./src/test/archive/sample_db/convert_chain_to_canonical.sh postgres://postgres:postgres@localhost:5432/archive
3941
40- echo Regenerateing precomputed_blocks.tar.xz
42+ echo Regenerating precomputed_blocks.tar.xz
4143rm -rf precomputed_blocks || true
4244mkdir precomputed_blocks
4345find ~ /.mina-network -name ' precomputed_blocks.log' | xargs -I ! ./scripts/mina-local-network/split_precomputed_log.sh ! precomputed_blocks
4446rm ./src/test/archive/sample_db/precomputed_blocks.tar.xz || true
45- tar cvf ./src/test/archive/sample_db/precomputed_blocks.tar.xz precomputed_blocks
47+ tar -C precomputed_blocks - cvf ./src/test/archive/sample_db/precomputed_blocks.tar.xz .
4648rm -rf precomputed_blocks
4749
48- echo Regenerateing archive_db.sql
50+ echo Regenerating archive_db.sql
4951pg_dump -U postgres -d archive > ./src/test/archive/sample_db/archive_db.sql
5052
5153
52- echo Regenerateing input file
54+ echo Regenerating input file
5355cp ./scripts/mina-local-network/annotated_ledger.json _tmp.json
54- echo ' { "genesis_ledger": { "accounts": ' $( cat _tmp.json | jq ' .accounts' ) ' , "num_accounts": ' $( cat _tmp.json | jq ' .num_accounts' ) ' }}' \
56+ echo ' { "genesis_ledger": { "accounts": ' " $( cat _tmp.json | jq ' .accounts' ) " ' , "num_accounts": ' " $( cat _tmp.json | jq ' .num_accounts' ) " ' }}' \
5557 | jq -c > ./src/test/archive/sample_db/replayer_input_file.json
5658rm _tmp.json
5759
58- echo Regenerateing genesis_ledger
59- cat src/test/archive/sample_db/genesis.json | jq " .ledger=$( cat ~ /.mina-network/mina-local-network-2-1-1/genesis_ledger.json | jq -c) " > _tmp.json
60+ echo Regenerating genesis_ledger
61+ cat src/test/archive/sample_db/genesis.json | jq " .ledger=$( cat $LOCAL_NETWORK_DATA_FOLDER /genesis_ledger.json | jq -c) " > _tmp.json
62+ # update genesis_state_timestamp to the one from daemon.json
63+ jq --arg timestamp " $( cat $LOCAL_NETWORK_DATA_FOLDER /daemon.json | jq -r ' .genesis.genesis_state_timestamp' ) " ' .genesis.genesis_state_timestamp = $timestamp' _tmp.json > _tmp2.json && mv _tmp2.json _tmp.json
64+
6065mv _tmp.json src/test/archive/sample_db/genesis.json
6166
6267echo finished regenerate testing replay
0 commit comments