mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 09:53:47 +01:00
799968e8b3
- mention 'Lost X events' workaround - clarify flush tracepoint docs - fix typo in tracepoint context - clarify flush for prune The documentation and examples for the `fFlushForPrune` argument of the utxocache flush tracepoint weren't clear without looking at the code. See these comments: https://github.com/bitcoin/bitcoin/pull/22902#issuecomment-987094612 - doc: note that there can be temporary UTXO caches Bitcoin Core uses temporary clones of it's _main_ UTXO cache in some places. The utxocache:add and :spent tracepoints are triggered when temporary caches are changed too. This is documented.
87 lines
1.8 KiB
Plaintext
Executable File
87 lines
1.8 KiB
Plaintext
Executable File
#!/usr/bin/env bpftrace
|
|
|
|
/*
|
|
|
|
USAGE:
|
|
|
|
bpftrace contrib/tracing/log_utxos.bt
|
|
|
|
This script requires a 'bitcoind' binary compiled with eBPF support and the
|
|
'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is
|
|
located in './src/bitcoind'. This can be modified in the script below.
|
|
|
|
NOTE: requires bpftrace v0.12.0 or above.
|
|
*/
|
|
|
|
BEGIN
|
|
{
|
|
printf("%-7s %-71s %16s %7s %8s\n",
|
|
"OP", "Outpoint", "Value", "Height", "Coinbase");
|
|
}
|
|
|
|
/*
|
|
Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache.
|
|
*/
|
|
usdt:./src/bitcoind:utxocache:add
|
|
{
|
|
$txid = arg0;
|
|
$index = (uint32)arg1;
|
|
$height = (uint32)arg2;
|
|
$value = (int64)arg3;
|
|
$isCoinbase = arg4;
|
|
|
|
printf("Added ");
|
|
$p = $txid + 31;
|
|
unroll(32) {
|
|
$b = *(uint8*)$p;
|
|
printf("%02x", $b);
|
|
$p-=1;
|
|
}
|
|
|
|
printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));
|
|
}
|
|
|
|
/*
|
|
Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache.
|
|
*/
|
|
usdt:./src/bitcoind:utxocache:spent
|
|
{
|
|
$txid = arg0;
|
|
$index = (uint32)arg1;
|
|
$height = (uint32)arg2;
|
|
$value = (int64)arg3;
|
|
$isCoinbase = arg4;
|
|
|
|
printf("Spent ");
|
|
$p = $txid + 31;
|
|
unroll(32) {
|
|
$b = *(uint8*)$p;
|
|
printf("%02x", $b);
|
|
$p-=1;
|
|
}
|
|
|
|
printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));
|
|
}
|
|
|
|
/*
|
|
Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache.
|
|
*/
|
|
usdt:./src/bitcoind:utxocache:uncache
|
|
{
|
|
$txid = arg0;
|
|
$index = (uint32)arg1;
|
|
$height = (uint32)arg2;
|
|
$value = (int64)arg3;
|
|
$isCoinbase = arg4;
|
|
|
|
printf("Uncache ");
|
|
$p = $txid + 31;
|
|
unroll(32) {
|
|
$b = *(uint8*)$p;
|
|
printf("%02x", $b);
|
|
$p-=1;
|
|
}
|
|
|
|
printf(":%-6d %16ld %7d %s\n", $index, $value, $height, ($isCoinbase ? "Yes" : "No" ));
|
|
}
|