Bitcoin Forum
May 27, 2024, 12:11:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Merkle Tree Bits bug??  (Read 616 times)
cross1943 (OP)
Member
**
Offline Offline

Activity: 60
Merit: 10

http://xingfeng.org


View Profile WWW
January 20, 2014, 07:55:28 AM
Last edit: January 20, 2014, 10:06:40 AM by cross1943
 #1

a. send net message:

    1. filterload( BloomFilter( 100, 0.000001, BLOOM_UPDATE_NONE ) );

    2. filteradd( fromhex("27a1f12771de5cc3b73941664b2537c15316be43") );

    3. getdata( fromhex("0000000000000001cfee50480e82a9fd91bbee46b8ef2c8cbb0dcdfd658eac68"), MSG_FILTERED_BLOCK );

b. wait net message with merkle block data.
    merkleblock:
        CBlockHeader
              .....
        CPartialMerkleTree
              nTransactions
              vHash
              vBits

nTransactions = 640;
Code:
size_t get_tree_height( size_t nTransactions )
{
    double v = log( double( nTransactions ) ) / log( 2.0f ); // log2(nTransactions)
    if( fmod( v, 1 ) > 0 )
    {
        return size_t( v ) + 1;
    }
    return size_t( v );
}
so, i'm calculation the merkle tree height = 10;
and check it, because  2^9=512, and  2^10=1024.
so i think it's right height with the transaction count.

and
count(vHash)=11;
tohex(vBits) = "ff0700";

expand the vBits to <bool>:
  (true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false)

at prefix, has 11's true.
and, this tree branch count equal 1.
so, in the branch tree bottom, has 2 true node, (and the 2 tx-hash).
your can draw a tree bitmap to check it.
i think, i can get 2 tx?
( but...Im only put a filter key...maby it's bloom filter to two record. )

c. wait net message with "tx".
    im only revice 1 tx.. not 2 tx??

so, im think it's the vBits BUG?? it is not the filter problem.

and,  when im add other filter key, when the branch count greater 2, the bottom tx count is right. not this problem.
example:

block: 0000000000000000e0adedd30a9cdce5638bf507c769956dd8563ecfd2ff2a82
key:
    27a1f12771de5cc3b73941664b2537c15316be43
    8485f40e69b1bd95660a0b866ac250532d52c085
    cf14cc39c079f294049e94e11543f342277fc863

Im test the branch bottom's true node count was equal 3 from my calc_bottom_function.
it's right tx count with it.


The problem only be in branch count equal 1 ??

cross1943 (OP)
Member
**
Offline Offline

Activity: 60
Merit: 10

http://xingfeng.org


View Profile WWW
January 20, 2014, 10:03:42 AM
 #2

oh...it's my problem....when calculation the bottom node, it's must make height + 1 tree

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!