Skip to content

Commit

Permalink
Refactor script to use ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Sep 27, 2024
1 parent 0d5cfd1 commit f7666f8
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions scripts/delta_state_dumps.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
#!/usr/bin/env bash

# If there are a lot of transactions, it can be difficult to quit the script. This prompts if the user wants to continue after each diff.
# If there are a lot of transactions, it can be difficult to quit the script. This prompts if the user wants to diff the tx, allowing Ctrl+C.
function prompt_continue {
while true; do
read -rp "Continue [Y/n]? " yn
read -rp "Diff [Y/n]? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) break;;
[Nn]* ) return 1;;
* ) return 0;;
esac
done
}

for block_dir in state_dumps/vm/*/; do
[ -d "$block_dir" ] || continue
block_base=$(basename "$block_dir")
for block in state_dumps/vm/*/; do
[ -d "$block" ] || continue
block_name=$(basename "$block")

echo "Block ${block_base//block/}"
echo "Block ${block_name//block/}"

for vm_dump in "$block_dir"/*.json; do
[ -f "$vm_dump" ] || continue
native_dump="${vm_dump//vm/native}"
# Compares the files in ascending order, by creation date
IFS=$'\n'
for tx_name in $(ls -trU1 $block); do
vm_tx="state_dumps/vm/$block_name/$tx_name"
native_tx="state_dumps/native/$block_name/$tx_name"

if cmp -s \
<(sed '/"reverted": /d' "$native_dump") \
<(sed '/"reverted": /d' "$vm_dump")
<(sed '/"reverted": /d' "$native_tx") \
<(sed '/"reverted": /d' "$vm_tx")
then
continue
fi

base=$(basename "$vm_dump")
echo "Tx ${base//.json/}"
echo "Tx ${tx_name//.*/}"

prompt_continue

delta "$native_dump" "$vm_dump" --side-by-side --paging always --wrap-max-lines unlimited
prompt_continue && {
delta "$native_tx" "$vm_tx" --side-by-side --paging always --wrap-max-lines unlimited
}
done
done

0 comments on commit f7666f8

Please sign in to comment.