Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: namecoin on September 09, 2015, 07:53:41 AM



Title: Optimize checkblock transaction checking on Bitcoin Core
Post by: namecoin on September 09, 2015, 07:53:41 AM
It seems that we might be able to optimize some transaction checkings. 
Many checkings are done twice:
1. when the transaction is placed into the pool
2. when verifying validity of the transaction in a block

Why don't we simply check if the transaction in a block is already in the memory pool?  The transaction is already verified when it is placed into the pool. 

Does this makes sense?  If so, is there a reason that bitcoind does not want to do this?   ???

Thank you very much for your review.


Title: Re: Optimize checkblock transaction checking on Bitcoin Core
Post by: amaclin on September 09, 2015, 08:18:59 AM
It seems that we might be able to optimize some transaction checkings. 
Many checkings are done twice:
1. when the transaction is placed into the pool
2. when verifying validity of the transaction in a block
Yes, may be some checks can be skipped (if not already)
But.
1) What do you want to achieve?
2) Can you calculate (in btc or bucks or kwh) the benefits of this refactoring?
3) Can you rewrite code yourself and submit a pull-request?


Title: Re: Optimize checkblock transaction checking on Bitcoin Core
Post by: DannyHamilton on September 09, 2015, 11:30:17 AM
I think it would be a problem to just check if the transaction is already in the memory pool, wouldn't it?

Isn't it possible for other transactions that are already in the block to make some transactions in the memory pool invalid?


Title: Re: Optimize checkblock transaction checking on Bitcoin Core
Post by: amaclin on September 09, 2015, 11:59:05 AM
It is possible to skip ECDSA signature verification if it was passed before.
As far as I remember Bitcoin Core Client caches valid signatures (but I do not know the size of this LRU cache).

Anyway, one is able to make any changes in code and add/remove any checks.
Just do it yourself and tell us about the results.


Title: Re: Optimize checkblock transaction checking on Bitcoin Core
Post by: namecoin on September 10, 2015, 10:25:02 AM
It seems that we might be able to optimize some transaction checkings.  
Many checkings are done twice:
1. when the transaction is placed into the pool
2. when verifying validity of the transaction in a block
Yes, may be some checks can be skipped (if not already)
But.
1) What do you want to achieve?
2) Can you calculate (in btc or bucks or kwh) the benefits of this refactoring?
3) Can you rewrite code yourself and submit a pull-request?


Thanks for the inputs, amaclin and DannyHamilton.

1) Increase the tps that a node can process.  It seems that our test machine cannot process more than 15 transactions per seconds (not talking about mining or blocksize).
3) My friend has the change already and can submit a pull-request.  


Title: Re: Optimize checkblock transaction checking on Bitcoin Core
Post by: namecoin on September 17, 2015, 06:58:32 AM
FYI. The pull request filed earlier.
https://github.com/bitcoin/bitcoin/pull/6659