Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions .github/workflows/daily-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -698,73 +698,6 @@ jobs:
exit 1
fi

# # Test USDT tracing functionality if enabled
# if [ "${{ matrix.config.enable_usdt }}" == "true" ]; then
# echo "---------------- Start USDT tracing tests ---------------- "
# cd "$BASE_ROOT_DIR"

# # Install BCC and bpftrace for USDT testing (Linux only)
# if [ "${{ matrix.config.platform }}" == "linux" ]; then
# echo "Installing BCC and bpftrace for tracing tests..."
# # Install BCC for Python USDT scripts
# python3 -m pip install bcc --user --quiet || echo "Warning: BCC installation failed"

# # Install bpftrace for .bt scripts (already installed in setup, but ensure it's available)
# which bpftrace || echo "Warning: bpftrace not available"

# # Run USDT functional tests (excluding coinselection as it tests non-existent tracepoints)
# echo "Running USDT functional tests..."
# if python3 test/functional/test_runner.py \
# --tmpdir="$TAPYRUS_TEST_DIR" \
# -j 1 \
# --combinedlogslen=4000 \
# --usdt \
# interface_usdt_mempool.py \
# interface_usdt_net.py \
# interface_usdt_utxocache.py; then
# echo "USDT functional tests passed"
# else
# echo "USDT functional tests failed, continuing..."
# fi

# # Test contrib tracing scripts with a short tapyrusd run
# echo "Testing contrib tracing scripts..."
# mkdir -p "$TAPYRUS_TEST_DIR/tracing_test"

# # Start tapyrusd in background for tracing tests
# cd "$BASE_BUILD_DIR/bin"
# ./tapyrusd -datadir="$TAPYRUS_TEST_DIR/tracing_test" -daemon -regtest -txindex=1 -fallbackfee=0.0002 || echo "Failed to start tapyrusd"
# sleep 5

# # Test Python tracing scripts (run each for 5 seconds)
# cd "$BASE_ROOT_DIR"
# for script in contrib/tracing/*.py; do
# if [ -f "$script" ]; then
# echo "Testing $(basename $script)..."
# timeout 5 python3 "$script" "$BASE_BUILD_DIR/bin/tapyrusd" &>/dev/null || echo "Script $(basename $script) test completed"
# fi
# done

# # Test bpftrace scripts syntax (without running, as they require root)
# for script in contrib/tracing/*.bt; do
# if [ -f "$script" ] && command -v bpftrace >/dev/null; then
# echo "Checking syntax of $(basename $script)..."
# bpftrace --dry-run "$script" &>/dev/null && echo "$(basename $script) syntax OK" || echo "$(basename $script) syntax issues"
# fi
# done

# # Stop tapyrusd
# ./tapyrus-cli -datadir="$TAPYRUS_TEST_DIR/tracing_test" -regtest stop 2>/dev/null || pkill tapyrusd
# sleep 2

# echo "USDT tracing scripts tested"
# else
# echo "Skipping USDT tracing tests on ${{ matrix.config.platform }} (Linux only)"
# fi
# else
# echo "Skipping USDT tracing tests (USDT disabled)"
# fi

echo "---------------- Start daily functional test suite ---------------- "
cd "$BASE_ROOT_DIR"
# Run the daily functional test suite including long-running tests
Expand Down
10 changes: 9 additions & 1 deletion cmake/module/FindUSDT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ if(APPLE)
endif()
else()
# On Linux, look for systemtap headers
# Try to find sys/sdt.h in standard and architecture-specific locations
find_path(USDT_INCLUDE_DIR
NAMES sys/sdt.h
PATHS
/usr/include
/usr/local/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/include/x86_64-linux-gnu
/usr/include/aarch64-linux-gnu
/usr/include/arm-linux-gnueabihf
)
mark_as_advanced(USDT_INCLUDE_DIR)

Expand Down Expand Up @@ -74,5 +82,5 @@ if(USDT_FOUND AND NOT TARGET USDT::headers)
set_target_properties(USDT::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${USDT_INCLUDE_DIR}"
)
set(ENABLE_TRACING TRUE)
set(ENABLE_TRACING ON)
endif()
2 changes: 1 addition & 1 deletion contrib/tracing/connectblock_benchmark.bt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ usdt:./src/tapyrusd:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2
blocks where the time it took to connect the block is above the
<logging threshold in ms>.
*/
usdt:./src/tapyrusd:validation:block_connected / (uint64) arg5 / 1000> $3 /
usdt:./src/tapyrusd:validation:block_connected / (uint64) arg5 / 1000 > $3 /
{
$hash = arg0;
$height = (int32) arg1;
Expand Down
26 changes: 14 additions & 12 deletions contrib/tracing/log_coinselection.bt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ BEGIN

usdt:./src/tapyrusd:coin_selection:coins_requested
{
@value = (uint64)arg0;
$wallet = str(arg0);
$color = str(arg1);
@value = (uint64)arg2;

printf("Request [%s] : value [%d]\n", $color, @value);
printf("Request wallet [%s] [%s] : value [%d]\n", $wallet, $color, @value);
}

usdt:./src/tapyrusd:coin_selection:selected_coins
{
$color = str(arg0);
@value = (uint64)arg1;
@mapValueIn = (uint64)arg2;
$algo = str(arg0);
$color = str(arg1);
@value = (uint64)arg2;
@count = (uint64)arg3;
$algo = str(arg4);
@mapValueIn = (uint64)arg4;

printf("Select [%s]: try to select [%d] using [%d]", $color, @value, @count);
printf(" coins of total value [%d]", @mapValueIn);
Expand All @@ -28,16 +29,17 @@ usdt:./src/tapyrusd:coin_selection:selected_coins

usdt:./src/tapyrusd:coin_selection:change_info
{
@amount = (uint64)arg0;
$color = str(arg1);
$color = str(arg0);
@position = (uint64)arg1;
@amount = (uint64)arg2;

printf("Change [%s] : value [%d]\n", $color, @amount);
printf("Change [%s] : position [%d] value [%d]\n", $color, @position, @amount);
}

usdt:./src/tapyrusd:coin_selection:fee_info
{
@fee = (uint64)arg0;
@fee_need = (uint64)arg1;
@fee_need = (uint64)arg0;
@fee = (uint64)arg1;

printf("Fee [TPC] : value [%d] need [%d]\n", @fee, @fee_need);
printf("Fee [TPC] : need [%d] value [%d]\n", @fee_need, @fee);
}
9 changes: 5 additions & 4 deletions doc/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ Arguments passed:
Is called when a coin is added to a UTXO cache. This can be a temporary UTXO cache too.

Arguments passed:
1. Transaction ID (hash) as `pointer to unsigned chars` (i.e. 64 bytes hex string in little-endian)
1. Transaction ID (hash) as `pointer to C-style string` (64 bytes)
2. Output index as `uint32`
3. Block height the coin was added to the UTXO-set as `uint32`
4. Value of the coin as `int64`
5. If the coin is a coinbase as `bool`
3. Token name as `pointer to C-style string`(66 bytes)
4. Block height the coin was added to the UTXO-set as `uint32`
5. Value of the coin as `int64`
6. If the coin is a coinbase as `bool`

#### Tracepoint `utxocache:utxocache_spent`

Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,11 @@ static bool AcceptToMemoryPoolWorker(const CTransactionRef &ptx, CTxMempoolAccep
TRACE7(mempool, replaced,
it->GetTx().GetHashMalFix().begin(),
it->GetTxSize(),
nModifiedFees,
it->GetModifiedFee(),
it->GetTime(),
hash.begin(),
tx.GetTotalSize(),
nConflictingFees
nModifiedFees
);
opt.txnReplaced.push_back(it->GetSharedTx());
}
Expand Down
13 changes: 7 additions & 6 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac

for ([[maybe_unused]]const auto& entity:mapValue)
{
TRACE2(coin_selection, coins_requested, entity.second, entity.first.toHexString().c_str());
TRACE3(coin_selection, coins_requested, GetName().c_str(), entity.first.toHexString().c_str(), entity.second);
}

if (vecSend.empty())
Expand Down Expand Up @@ -2836,7 +2836,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
return false;
}
}
TRACE5(coin_selection, selected_coins, colorId.toHexString().c_str(), targetValue, mapValueIn[colorId], mapCoins[colorId].size(), bnb_used ? "BNB" : "knapsack");
TRACE5(coin_selection, selected_coins, bnb_used ? "BNB" : "knapsack", colorId.toHexString().c_str(), targetValue, mapCoins[colorId].size(), mapValueIn[colorId]);
}
} else {
bnb_used = false;
Expand All @@ -2862,7 +2862,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
// add colored coin change at the end
mapChangePosInOut[colorId] = txNew.vout.size();
txNew.vout.push_back(newTxOut);
TRACE2(coin_selection, change_info, nChange, colorId.toHexString().c_str());
TRACE3(coin_selection, change_info, colorId.toHexString().c_str(), mapChangePosInOut[colorId], nChange);
}
else
mapChangePosInOut[colorId] = -1;
Expand All @@ -2877,7 +2877,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
const CAmount nChange = mapValueIn[colorId] - targetValue;
if (nChange > 0)
{
TRACE2(coin_selection, change_info, &nChange, colorId.toHexString().c_str());
// Fill a vout to ourself
CTxOut newTxOut(nChange, scriptChange);

Expand All @@ -2898,6 +2897,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
//add change output to the end
mapChangePosInOut[colorId] = txNew.vout.size();
txNew.vout.push_back(newTxOut);
TRACE3(coin_selection, change_info, colorId.toHexString().c_str(), mapChangePosInOut[colorId], nChange);
}
else
{
Expand All @@ -2908,6 +2908,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
}
std::vector<CTxOut>::iterator position = txNew.vout.begin()+mapChangePosInOut[colorId];
txNew.vout.insert(position, newTxOut);
TRACE3(coin_selection, change_info, colorId.toHexString().c_str(), mapChangePosInOut[colorId], nChange);

//colored coin change outputs may be incorrect after this insert. fix them
for(auto& i : mapChangePosInOut)
Expand Down Expand Up @@ -2980,7 +2981,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
change_position->nValue += extraFeePaid;
nFeeRet -= extraFeePaid;
}
TRACE2(coin_selection, fee_info, nFeeRet, nFeeNeeded);
TRACE2(coin_selection, fee_info, nFeeNeeded, nFeeRet);
break; // Done, enough fee included.
}
else if (!pick_new_inputs) {
Expand All @@ -3000,7 +3001,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
if (change_position->nValue >= MIN_FINAL_CHANGE + additionalFeeNeeded) {
change_position->nValue -= additionalFeeNeeded;
nFeeRet += additionalFeeNeeded;
TRACE2(coin_selection, fee_info, nFeeRet, nFeeNeeded);
TRACE2(coin_selection, fee_info, nFeeNeeded, nFeeRet);
break; // Done, able to increase fee from change
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ if(NOT ENABLE_ZMQ)
set(ENABLE_ZMQ_TRUE "#")
endif()

if(NOT ENABLE_TRACING)
set(ENABLE_TRACING_TRUE "#")
endif()

# Create build ini file in build and source dir
configure_file(config.ini.in config.ini USE_SOURCE_PERMISSIONS @ONLY)
configure_file(config.ini.in ${abs_top_srcdir}/test/config.ini USE_SOURCE_PERMISSIONS @ONLY)
Expand Down
2 changes: 1 addition & 1 deletion test/config.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
@BUILD_GENESIS_TRUE@BUILD_GENESIS=true
@ENABLE_WALLET_TRUE@ENABLE_WALLET=true
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
@ENABLE_USDT_TRACEPOINTS_TRUE@ENABLE_USDT_TRACEPOINTS=true
@ENABLE_TRACING_TRUE@ENABLE_TRACING=true
Loading
Loading