Skip to content

Commit

Permalink
Merge pull request #9188 from MinaProtocol/feature/merge-1.2.0-to-com…
Browse files Browse the repository at this point in the history
…patible

Merge 1.2.0 back to compatible
  • Loading branch information
lk86 authored Jul 14, 2021
2 parents 4921632 + e9916a1 commit 95c66c8
Show file tree
Hide file tree
Showing 10 changed files with 17,816 additions and 60 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile-mina-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RUN apt-get -y update && \
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
&& apt-get update \
&& apt-get install -y google-cloud-sdk
&& apt-get install -y google-cloud-sdk kubectl

# Mina daemon package
# jemalloc is also installed automatically here to match the package dependencies for this $deb_codename
Expand Down
54 changes: 39 additions & 15 deletions scripts/archive/fix-all-balances.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,55 @@
# use the URI for your archive db
ARCHIVE_URI=${ARCHIVE_URI:-postgres://postgres@localhost:5432/archive}

# use the log file generated with `awk -f scripts/archive/find-swapped-balances.awk replayer.log > swapped-balances.log`
# logs from the replayer
REPLAYER_LOG=${REPLAYER_LOG:-replayer.log}

# the log file generated with AWK script run on replayer log
LOG_FILE=${LOG_FILE:-swapped-balances.log}

# binary name/location for the mina replayer tool
REPLAYER=mina-replayer

# binary name/location for the mina swap bad balances tool
SWAPPER=mina-swap-bad-balances

REPLAYER_TEMPLATE=scripts/archive/replayer_template.json
REPLAYER_INPUT=replayer_input.json

# Read over each line of the LOG_FILE and call SWAPPER on each STATE_HASH, SEQ_NUMBER pair
while read -r
do
read -p "State hash from canonical chain: " STATE_HASH

EXTRACTED_HASH=$(printf "%s\n" "$REPLY" | jq -rM .metadata.state_hash)
cp $REPLAYER_TEMPLATE $REPLAYER_INPUT

case "$EXTRACTED_HASH" in
sed --in-place s/REPLACETHIS/$STATE_HASH/ $REPLAYER_INPUT

null)
EXTRACTED_MESSAGE=$(printf "%s\n" "$REPLY" | jq -rM .message)
SEQ_NUMBER="${EXTRACTED_MESSAGE##* }"
echo "---- Swapping balances for state hash ${STATE_HASH} at sequence number ${SEQ_NUMBER} ----"
"${SWAPPER}" --archive-uri "${ARCHIVE_URI}" --state-hash "${STATE_HASH}" --sequence-no "${SEQ_NUMBER}"
;;
echo "---- Running replayer (takes several minutes)"
$REPLAYER --archive-uri "${ARCHIVE_URI}" --input-file replayer_input.json --output-file /dev/null > ${REPLAYER_LOG}

*)
STATE_HASH=$EXTRACTED_HASH
rm -f $REPLAYER_INPUT

esac
echo "---- Finding swapped balances"
awk -f scripts/archive/find-swapped-balances.awk ${REPLAYER_LOG} > ${LOG_FILE}

BAD_COUNT=$(grep -- "-----" $LOG_FILE | wc -l)

echo "Found $BAD_COUNT swapped balances"

# Read over each line of the LOG_FILE and call SWAPPER on each STATE_HASH, SEQ_NUMBER pair
while read -r
do
if [[ ${REPLY} != "---------------" ]]; then

EXTRACTED_HASH=$(printf "%s\n" "$REPLY" | jq -rM .metadata.state_hash)
case "$EXTRACTED_HASH" in
null)
EXTRACTED_MESSAGE=$(printf "%s\n" "$REPLY" | jq -rM .message)
SEQ_NUMBER="${EXTRACTED_MESSAGE##* }"
echo "---- Swapping balances for state hash ${STATE_HASH} at sequence number ${SEQ_NUMBER} ----"
"${SWAPPER}" --archive-uri "${ARCHIVE_URI}" --state-hash "${STATE_HASH}" --sequence-no "${SEQ_NUMBER}"
;;

*)
STATE_HASH=$EXTRACTED_HASH
esac
fi
done <"$LOG_FILE"
Loading

0 comments on commit 95c66c8

Please sign in to comment.