Skip to content

Commit

Permalink
Merge pull request #73 from lambdaclass/update-block-count-scripts
Browse files Browse the repository at this point in the history
Update Scripts to count tx state dumps diff
  • Loading branch information
JulianGCalderon authored Oct 28, 2024
2 parents a9af919 + e2c9181 commit 4b32b84
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
19 changes: 18 additions & 1 deletion scripts/cmp_state_dumps.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
#!/usr/bin/env bash

# Compares state dump files between two directories: 'state_dumps/vm' and 'state_dumps/native'.
# It iterates over all JSON files in the 'state_dumps/vm' directory and checks if the corresponding
# file exists in 'state_dumps/native'.
# If the corresponding file does not exist, it skips the comparison and counts the missing files.
# For existing pairs, it compares the contents, ignoring the lines containing the "reverted" field, because of error message diference in Native and VM.
# It counts and displays the number of matching, differing, and missing state dumps.

matching=0
diffing=0
missing=0

# Iterate over state_dumps/vm dumps
for vm_dump in state_dumps/vm/*/*.json; do
[ -f "$vm_dump" ] || continue

native_dump="${vm_dump//vm/native}"

base=$(basename "$native_dump")
# Check if the corresponding native_dump file exists, if not, skip
if [ ! -f "$native_dump" ]; then
echo "Missing: $native_dump (file not found)"
missing=$((missing+1))
continue
fi

base=$(basename "$vm_dump")

if ! cmp -s \
<(sed '/"reverted": /d' "$native_dump") \
Expand All @@ -26,3 +42,4 @@ echo
echo "Finished comparison"
echo "- Matching: $matching"
echo "- Diffing: $diffing"
echo "- Missing: $missing"
10 changes: 8 additions & 2 deletions scripts/delta_state_dumps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ for block in state_dumps/vm/*/; do
# 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"
vm_tx="state_dumps/vm/$block_name/$tx_name"

# Check if the corresponding native_tx file exists, if not, skip
if [ ! -f "$native_tx" ]; then
echo "Skipping: $native_tx (file not found)"
continue
fi

if cmp -s \
<(sed '/"reverted": /d' "$native_tx") \
Expand All @@ -33,7 +39,7 @@ for block in state_dumps/vm/*/; do
echo "Tx ${tx_name//.*/}"

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

0 comments on commit 4b32b84

Please sign in to comment.