Get details from transaction differences in `getrawmempool` (#6035)
* add `ZCASH_RPC_COOKIE_FILE` env var * get details when `getrawmempool` call differs * remove non needed cookie file argument in zebra call * replace cookie args with extra agrs * read hex from file * use jq for transactions loop * dump transactions from the zcashd mempool * apply suggestions from code review Co-authored-by: teor <teor@riseup.net> --------- Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
53c6890fa2
commit
ed22dff17b
|
@ -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
|
||||
|
@ -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/')
|
||||
|
@ -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 ' ,"')
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue