Bitcoin Forum
May 26, 2024, 11:39:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Calculating WitnessSigOps on: November 07, 2022, 12:27:08 PM
Bitcoin nodes calculate  signature operations for transactions and limit to amount of operations. Currently, max is
80,000 https://github.com/bitcoin/bitcoin/blob/24.x/src/consensus/consensus.h#L16-L17. Presumably, this is to prevent DoS type of attacks . If nodes spend all their time checking sigs, they won't keep up.


Function WitnessSigOps https://github.com/bitcoin/bitcoin/blob/24.x/src/script/interpreter.cpp#L2072-L2087 simply checks the size of SegWit v0 data and returns a cost of 1.
(See WITNESS_V0_KEYHASH_SIZE https://github.com/bitcoin/bitcoin/blob/24.x/src/script/interpreter.h#L226 )


Is it possible to construct a tx such that bitcoin nodes believe total signature operation costs is low, but in actuality nodes end up wasting CPU cycles and fail to catch up with the tip?

2  Bitcoin / Development & Technical Discussion / Re: MoneyRange() allows zero? on: April 13, 2022, 11:13:49 AM
in tx_check.cpp

Code:
// Check for negative or overflow output values (see CVE-2010-5139)
CAmount nValueOut = 0;
for (const auto& txout : tx.vout)
{
     if (txout.nValue < 0)
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vout-negative");
     if (txout.nValue > MAX_MONEY)
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vout-toolarge");
     nValueOut += txout.nValue;
     if (!MoneyRange(nValueOut))
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-txouttotal-toolarge");
}

It looks like you can
3  Bitcoin / Development & Technical Discussion / MoneyRange() allows zero? on: April 13, 2022, 10:45:38 AM
In MoneyRange():
Code:
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
Zero is valid.

I can see how fees can be zero, but is it possible for CAmount in a transaction (e.g. p2wh address1 --> address2) be zero?

4  Bitcoin / Development & Technical Discussion / Re: BCLog::Bench - Timing nothing of value on: September 23, 2021, 08:51:36 AM
Thanks

PR https://github.com/bitcoin/bitcoin/pull/23072

Issue https://github.com/bitcoin/bitcoin/issues/23071
5  Bitcoin / Development & Technical Discussion / BCLog::Bench - Timing nothing of value on: September 22, 2021, 02:44:28 PM
I recently setup up a new node and was perplexed why processing the chain took longer than expected.
I'm downloading  from another node on my local gigabit network, so bandwidth wasn't my bottleneck. 
I saw a -debug flag with a bench property, so I enabled this setting.  Long story short, the disk I used was really slow.

Anyways, I came across some code that doesn't seem to time anything of value:


Code:
    int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4;
    LogPrint(BCLog::BENCH, "    - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5 - nTime4), nTimeIndex * MICRO, nTimeIndex * MILLI / nBlocksTotal);

    int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5;
    LogPrint(BCLog::BENCH, "    - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime6 - nTime5), nTimeCallbacks * MICRO, nTimeCallbacks * MILLI / nBlocksTotal);


This is in https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1873

Correct if I'm wrong, but it seems "Callbacks" is timing the execution of the "Index writing" LogPrintf along with some basic computations (nTime6 - nTime5)
Inspection of my debug.log indicates a consistent time of around  ~20-30 microseconds.

Is this timing anything of value?

Callbacks bench was added (I think) in this commit: https://github.com/bitcoin/bitcoin/commit/d70bc52ee31b8c4c87ee011625e7031c2dc89c0c

If this is dead (legacy) code, I'll open merge request and remove it. Could someone confirm ?

Thanks.
6  Bitcoin / Development & Technical Discussion / Re: Metrics in Bitcoin Core with Opentelemetry on: May 08, 2021, 07:16:46 PM
My intent is not to integrate this into Core, but to fork Core so that:

1. I learn about the bitcoin software architecture through metrics
2. integrate an abstract lib that can be configured to export to statsd or prometheus (or even both and others)

 https://github.com/jlopp/statoshi hard codes statsd, I personally want prometheus.

Opentelemetry-cpp seems to be flexible in collecting metrics.   I'm wondering if opentelemetry-cpp is stable and worth it...or maybe there's another way.


7  Bitcoin / Development & Technical Discussion / Metrics in Bitcoin Core with Opentelemetry on: May 08, 2021, 04:28:13 PM
jlopp has a great fork for node metrics  https://github.com/jlopp/statoshi and I'll like to extend it.
Currently statoshi only exports metrics to statsd but I want to the ability to write (easily) to another collector.
Opentelemetry ( https://github.com/open-telemetry/opentelemetry-cpp ) is one lib I found that provides an abstract interface and already has multiple collectors (e.g. https://github.com/open-o11y/docs/tree/master/cpp-prometheus)
Thoughts on this approach? Is there another lib or methodology that makes more sense?

 
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!