Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: fevirfevir on May 20, 2016, 02:47:09 PM



Title: Transaction verification time?
Post by: fevirfevir on May 20, 2016, 02:47:09 PM
Hi,

As from what I understand, Bitcoin nodes transmit transactions twice. First the actual transaction is transmitted; second, the transaction is included in a block and the block is transmitted, effectively transmitting the transaction twice.

The first time a transaction is transmitted, each node verifues the validity of a transaction, before further transmitting it. Again, from what I understand, if the transaction is included in a block, the (all) transaction(s) is (in the block are) verified, before the block is transmitted to the next node.

(Note: these questions are about transaction validity, not the transaction ultimately being accepted in the blockchain)

My questions:
1.a How long does it take to verify the validity of a single transaction (not included in a block)? I guess some assumptions must be made (CPU, memory, number of inouts/outputs in a transaction)
1.b Is there a tool available with which I can test and observe the verification time (of a single and/or multiple transactions)?
2. Is transaction validation of a single transaction (not included in a block) similar to transaction validation of a transaction in a block body?

Thanks.


Title: Re: Transaction verification time?
Post by: achow101 on May 20, 2016, 02:56:35 PM
My questions:
1.a How long does it take to verify the validity of a single transaction (not included in a block)? I guess some assumptions must be made (CPU, memory, number of inouts/outputs in a transaction)
It depends on the number of inputs and signature operations. A transaction could theoretically take several minutes to verify.

1.b Is there a tool available with which I can test and observe the verification time (of a single and/or multiple transactions)?
I'm not sure, but you can probably write one.

2. Is transaction validation of a single transaction (not included in a block) similar to transaction validation of a transaction in a block body?

Thanks.

Yes.


Title: Re: Transaction verification time?
Post by: cr1776 on May 20, 2016, 03:04:37 PM
You might also take a look at this:

https://m.reddit.com/r/Bitcoin/comments/3yulwv/any_examples_of_the_10_minute_script_thats_a/



Title: Re: Transaction verification time?
Post by: fevirfevir on May 23, 2016, 07:56:07 PM
The transaction verification time is mostly depended on the amonut of the transaction fee. The larger the transaction fee is, the higher the priority of the confirmation will be.

Ah, well, I meant the time it takes for a single node to verify the vallidity of a transaction. Not the time it takes for the entire network to accept the transaction as valid and incorporate it into the blockchain. In other words, checking the signature, checking the structure of the transaction, checking the content of the transaction fields, all that, how long does that take for a node (assumptions can be made on processor power, etc)? This should be independent of the tx fee.


Title: Re: Transaction verification time?
Post by: piotr_n on May 25, 2016, 07:40:19 AM
Ah, well, I meant the time it takes for a single node to verify the vallidity of a transaction. Not the time it takes for the entire network to accept the transaction as valid and incorporate it into the blockchain. In other words, checking the signature, checking the structure of the transaction, checking the content of the transaction fields, all that, how long does that take for a node (assumptions can be made on processor power, etc)? This should be independent of the tx fee.
Depending on the speed of the host computer, it should not be more than a couple milliseconds.

I think in bitcoin core, the most time consuming part these days would be fetching tx's input(s) from UTXO database. Unless they'd happen to be in a cache.
Then verifying ECDSA signature(s) also needs some time. But this has been hugely improved by switching to sipa's secp265k1 lib.


Title: Re: Transaction verification time?
Post by: amaclin on May 25, 2016, 09:35:08 PM
Depending on the speed of the host computer, it should not be more than a couple milliseconds.
Wrong. This is expensive process. Some transactions have very many inputs and SIGOPs.
Verifying them takes much more time even with secp265k1 lib


Title: Re: Transaction verification time?
Post by: piotr_n on May 26, 2016, 07:19:35 AM
Depending on the speed of the host computer, it should not be more than a couple milliseconds.
Wrong. This is expensive process. Some transactions have very many inputs and SIGOPs.
Verifying them takes much more time even with secp265k1 lib

OK, mr smart ass, let me rephrase.

If the transaction has less than 30 single-signature inputs, verifying it should not* take more than a couple milliseconds, on a $100+ CPU with secp265k1 lib.

Feeling better now?


* - by should not I mean that you haven't fucked up your code and it's aspiring to be optimal (e.g. by using parallel threads or not fetching the inputs from some slow database).


Title: Re: Transaction verification time?
Post by: amaclin on May 26, 2016, 08:01:37 AM
Feeling better now?
Aaaaah! Much better! (c) Duke Nukem