Add full diff objects to output #4

Merged
roysc merged 3 commits from add-data into main 2023-09-27 16:46:14 +00:00
3 changed files with 28 additions and 12 deletions

View File

@ -10,6 +10,6 @@ Use `scripts/compare-diffs.sh` to compare outputs of `go-ethereum/statediff` and
./scripts/compare-diffs.sh -d _var/ geth plugeth ./scripts/compare-diffs.sh -d _var/ geth plugeth
# Compare geth-statediff and the plugin using parallel iterators: # Compare geth-statediff and the plugin using parallel iterators:
./scripts/compare-diffs.sh -d _var/ geth plugeth ./scripts/compare-diffs.sh -d _var/ geth plugeth-parallel
A zero exit code indicates identical outputs, modulo possible duplicate nodes. A zero exit code indicates identical outputs, modulo possible duplicate nodes.

View File

@ -70,16 +70,35 @@ func writeDiff(outputDir string, number int, diff *statediff.StateObject) {
} }
defer f.Close() defer f.Close()
for _, item := range diff.IPLDs { for _, item := range diff.IPLDs {
if _, err = f.WriteString("ipld," + item.CID + "\n"); err != nil { s := fmt.Sprintf("ipld,%s,%x\n",
item.CID,
item.Content,
)
if _, err = f.WriteString(s); err != nil {
panic(err) panic(err)
} }
} }
for _, item := range diff.Nodes { for _, item := range diff.Nodes {
if _, err = f.WriteString("state," + item.AccountWrapper.CID + "\n"); err != nil { s := fmt.Sprintf("state,%s,%x,%t,%v,%v,%s,%x\n",
item.AccountWrapper.CID,
item.AccountWrapper.LeafKey,
item.Removed,
item.AccountWrapper.Account.Nonce,
item.AccountWrapper.Account.Balance,
item.AccountWrapper.Account.Root,
item.AccountWrapper.Account.CodeHash,
)
if _, err = f.WriteString(s); err != nil {
panic(err) panic(err)
} }
for _, storage := range item.StorageDiff { for _, storage := range item.StorageDiff {
if _, err = f.WriteString("storage," + storage.CID + "\n"); err != nil { s := fmt.Sprintf("storage,%s,%x,%t,%x\n",
storage.CID,
storage.LeafKey,
storage.Removed,
storage.Value,
)
if _, err = f.WriteString(s); err != nil {
panic(err) panic(err)
} }
} }

View File

@ -14,14 +14,12 @@ shift $((OPTIND - 1))
A=${1:-geth} A=${1:-geth}
B=${2:-plugeth} B=${2:-plugeth}
if [[ -n "$output_dir" ]]; then if [[ -z "$output_dir" ]]; then
mkdir -p $output_dir output_dir=$(mktemp -d)
fi
A_OUTPUT="$output_dir/A" A_OUTPUT="$output_dir/A"
B_OUTPUT="$output_dir/B" B_OUTPUT="$output_dir/B"
else
A_OUTPUT=$(mktemp -d -t A_XXXX)
B_OUTPUT=$(mktemp -d -t B_XXXX)
fi
./dumpdiff.$A $A_OUTPUT ./dumpdiff.$A $A_OUTPUT
./dumpdiff.$B $B_OUTPUT ./dumpdiff.$B $B_OUTPUT
@ -34,5 +32,4 @@ for file in $(ls $A_OUTPUT); do
mv $tmpfile "$dir/$file" mv $tmpfile "$dir/$file"
done done
(set -x; diff "${A_OUTPUT}/$file" "${B_OUTPUT}/$file") (set -x; diff "${A_OUTPUT}/$file" "${B_OUTPUT}/$file")
echo Files match: "$PLUGIN_OUTPUT/$file" "$GETH_OUTPUT/$file"
done done