Skip to content

Commit

Permalink
Merge of #6035
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 1, 2023
2 parents 53c6890 + 3eded4c commit 21eeaf0
Showing 1 changed file with 63 additions and 4 deletions.
67 changes: 63 additions & 4 deletions zebra-utils/zcash-rpc-diff
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ function usage()
ZCASH_CLI="${ZCASH_CLI:-zcash-cli}"
DIFF="${DIFF:-diff --unified --color=always}"
JQ="${JQ:-jq}"
# Zcashd authentication modes:
# - Use `-rpccookiefile=your/cookie/file` for a cookie file.
# - Use `-rpcpassword=your-password` for a password.
ZCASHD_EXTRA_ARGS="${ZCASHD_EXTRA_ARGS:-}"

if [ $# -lt 2 ]; then
usage
Expand All @@ -41,7 +45,7 @@ ZEBRAD=$(cat "$ZEBRAD_RELEASE_INFO" | grep '"subversion"' | cut -d: -f2 | cut -d
tr 'A-Z' 'a-z' | sed 's/magicbean/zcashd/ ; s/zebra$/zebrad/')

echo "Checking second node release info..."
$ZCASH_CLI getinfo > "$ZCASHD_RELEASE_INFO"
$ZCASH_CLI $ZCASHD_EXTRA_ARGS getinfo > "$ZCASHD_RELEASE_INFO"

ZCASHD=$(cat "$ZCASHD_RELEASE_INFO" | grep '"subversion"' | cut -d: -f2 | cut -d/ -f2 | \
tr 'A-Z' 'a-z' | sed 's/magicbean/zcashd/ ; s/zebra$/zebrad/')
Expand All @@ -60,7 +64,7 @@ ZEBRAD_NET=$(cat "$ZEBRAD_BLOCKCHAIN_INFO" | grep '"chain"' | cut -d: -f2 | tr -
ZEBRAD_HEIGHT=$(cat "$ZEBRAD_BLOCKCHAIN_INFO" | grep '"blocks"' | cut -d: -f2 | tr -d ' ,"')

echo "Checking $ZCASHD network and tip height..."
$ZCASH_CLI getblockchaininfo > "$ZCASHD_BLOCKCHAIN_INFO"
$ZCASH_CLI $ZCASHD_EXTRA_ARGS getblockchaininfo > "$ZCASHD_BLOCKCHAIN_INFO"

ZCASHD_NET=$(cat "$ZCASHD_BLOCKCHAIN_INFO" | grep '"chain"' | cut -d: -f2 | tr -d ' ,"')
ZCASHD_HEIGHT=$(cat "$ZCASHD_BLOCKCHAIN_INFO" | grep '"blocks"' | cut -d: -f2 | tr -d ' ,"')
Expand Down Expand Up @@ -93,7 +97,7 @@ time $ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" "$@" > "$ZEBRAD_RESPONSE"
echo

echo "Querying $ZCASHD $ZCASHD_NET chain at height >=$ZCASHD_HEIGHT..."
time $ZCASH_CLI "$@" > "$ZCASHD_RESPONSE"
time $ZCASH_CLI $ZCASHD_EXTRA_ARGS "$@" > "$ZCASHD_RESPONSE"
echo

echo
Expand All @@ -119,6 +123,9 @@ EXIT_STATUS=$?

if [ "$1" == "getaddressutxos" ]; then
set "getaddressbalance" "$2"
elif [ "$1" == "getrawmempool" ]; then
# Call `getrawmempool` again as a dummy request (this script isn't set up to do multiple cross-check calls)
set "getrawmempool"
else
exit $EXIT_STATUS
fi
Expand All @@ -136,7 +143,7 @@ echo "Querying $ZEBRAD $ZEBRAD_NET chain at height >=$ZEBRAD_HEIGHT..."
$ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" "$@" > "$ZEBRAD_CHECK_RESPONSE"

echo "Querying $ZCASHD $ZCASHD_NET chain at height >=$ZCASHD_HEIGHT..."
$ZCASH_CLI "$@" > "$ZCASHD_CHECK_RESPONSE"
$ZCASH_CLI $ZCASHD_EXTRA_ARGS "$@" > "$ZCASHD_CHECK_RESPONSE"

echo

Expand Down Expand Up @@ -192,6 +199,58 @@ if [ "$1" == "getaddressbalance" ]; then
fi
fi

if [ "$1" == "getrawmempool" ] && [ $CHECK_EXIT_STATUS != 0 ]; then
set TRANSACTION_ID
set TRANSACTION_HEX_FILE
set TRANSACTION_DECODED

ZEBRAD_TRANSACTION_IDS=$(cat "$ZEBRAD_RESPONSE" | $JQ -r 'join(" ")')
ZCASHD_TRANSACTION_IDS=$(cat "$ZCASHD_RESPONSE" | $JQ -r 'join(" ")')

echo
echo "# Dumping transactions from zebrad mempool"
echo

for TRANSACTION_ID in $ZEBRAD_TRANSACTION_IDS; do
TRANSACTION_HEX_FILE="$ZCASH_RPC_TMP_DIR/$ZEBRAD-$ZEBRAD_NET-$ZEBRAD_HEIGHT-$TRANSACTION_ID.json"

$ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" getrawtransaction $TRANSACTION_ID 0 > $TRANSACTION_HEX_FILE

echo "## Displaying transaction $TRANSACTION_ID from zebrad"
echo

# read the proposal data from a file, to avoid command-line length limits
TRANSACTION_DECODED=`cat "$TRANSACTION_HEX_FILE" | \
$ZCASH_CLI $ZCASHD_EXTRA_ARGS -stdin decoderawtransaction`

echo $TRANSACTION_DECODED | $JQ
echo
done

echo
echo "# Dumping transactions from zcashd mempool"
echo

for TRANSACTION_ID in $ZCASHD_TRANSACTION_IDS; do
TRANSACTION_HEX_FILE="$ZCASH_RPC_TMP_DIR/$ZCASHD-$ZCASHD_NET-$ZCASHD_HEIGHT-TRANSACTION_HEX-$TRANSACTION_ID.json"

$ZCASH_CLI $ZCASHD_EXTRA_ARGS getrawtransaction $TRANSACTION_ID 0 > $TRANSACTION_HEX_FILE

echo "## Displaying transaction $TRANSACTION_ID from zcashd"
echo

# read the proposal data from a file, to avoid command-line length limits
TRANSACTION_DECODED=`cat "$TRANSACTION_HEX_FILE" | \
$ZCASH_CLI $ZCASHD_EXTRA_ARGS -stdin decoderawtransaction`

echo $TRANSACTION_DECODED | $JQ
echo
done

fi

echo "Full RPC output is in $ZCASH_RPC_TMP_DIR"

if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
else
Expand Down

0 comments on commit 21eeaf0

Please sign in to comment.