OSDN Git Service

init push for tx status hash use merkle tree (#499)
authorPaladz <yzhu101@uottawa.ca>
Fri, 30 Mar 2018 01:58:09 +0000 (09:58 +0800)
committerGitHub <noreply@github.com>
Fri, 30 Mar 2018 01:58:09 +0000 (09:58 +0800)
* init push for tx status hash use merkle tree

* fix for unit test

* merkle tree func use intergace

12 files changed:
config/genesis.go
mining/mining.go
protocol/bc/bc.pb.go
protocol/bc/bc.proto
protocol/bc/merkle.go
protocol/bc/merkle_test.go
protocol/bc/tx_status.go
protocol/bc/tx_status_test.go
protocol/state/utxo_view_test.go
protocol/validation/block_test.go
protocol/validation/validation.go
protocol/validation/validation_test.go

index b8379c9..a65dc40 100644 (file)
@@ -37,21 +37,27 @@ func GenerateGenesisTx() *types.Tx {
 // GenerateGenesisBlock will return genesis block
 func GenerateGenesisBlock() *types.Block {
        genesisCoinbaseTx := GenerateGenesisTx()
-       merkleRoot, err := bc.MerkleRoot([]*bc.Tx{genesisCoinbaseTx.Tx})
+       merkleRoot, err := bc.TxMerkleRoot([]*bc.Tx{genesisCoinbaseTx.Tx})
        if err != nil {
-               log.Panicf("Fatal create merkelRoot")
+               log.Panicf("Fatal create tx merkelRoot")
        }
+
        txStatus := bc.NewTransactionStatus()
+       txStatus.SetStatus(0, false)
+       txStatusHash, err := bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
+       if err != nil {
+               log.Panicf("Fatal create tx status gmerkelRoot")
+       }
 
        block := &types.Block{
                BlockHeader: types.BlockHeader{
                        Version:   1,
                        Height:    0,
-                       Nonce:     4216083,
+                       Nonce:     4216085,
                        Timestamp: 1516788453,
                        BlockCommitment: types.BlockCommitment{
                                TransactionsMerkleRoot: merkleRoot,
-                               TransactionStatusHash:  bc.EntryID(txStatus),
+                               TransactionStatusHash:  txStatusHash,
                        },
                        Bits: 2305843009222082559,
                },
index 18c18ee..adb474a 100644 (file)
@@ -62,6 +62,7 @@ func createCoinbaseTx(accountManager *account.Manager, amount uint64, blockHeigh
 func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager *account.Manager) (b *types.Block, err error) {
        view := state.NewUtxoViewpoint()
        txStatus := bc.NewTransactionStatus()
+       txStatus.SetStatus(0, false)
        txEntries := []*bc.Tx{nil}
        gasUsed := uint64(0)
        txFee := uint64(0)
@@ -139,7 +140,11 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager
        }
        txEntries[0] = b.Transactions[0].Tx
 
-       b.BlockHeader.BlockCommitment.TransactionsMerkleRoot, err = bc.MerkleRoot(txEntries)
-       b.BlockHeader.BlockCommitment.TransactionStatusHash = bc.EntryID(txStatus)
+       b.BlockHeader.BlockCommitment.TransactionsMerkleRoot, err = bc.TxMerkleRoot(txEntries)
+       if err != nil {
+               return nil, err
+       }
+
+       b.BlockHeader.BlockCommitment.TransactionStatusHash, err = bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
        return b, err
 }
index a135ee9..086e406 100644 (file)
@@ -17,6 +17,7 @@ It has these top-level messages:
        ValueDestination
        BlockHeader
        TxHeader
+       TxVerifyResult
        TransactionStatus
        Mux
        Nonce
@@ -392,18 +393,42 @@ func (m *TxHeader) GetExtHash() *Hash {
        return nil
 }
 
+type TxVerifyResult struct {
+       StatusFail bool `protobuf:"varint,1,opt,name=status_fail,json=statusFail" json:"status_fail,omitempty"`
+}
+
+func (m *TxVerifyResult) Reset()                    { *m = TxVerifyResult{} }
+func (m *TxVerifyResult) String() string            { return proto.CompactTextString(m) }
+func (*TxVerifyResult) ProtoMessage()               {}
+func (*TxVerifyResult) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
+
+func (m *TxVerifyResult) GetStatusFail() bool {
+       if m != nil {
+               return m.StatusFail
+       }
+       return false
+}
+
 type TransactionStatus struct {
-       Bitmap []byte `protobuf:"bytes,1,opt,name=bitmap,proto3" json:"bitmap,omitempty"`
+       Version      uint64            `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
+       VerifyStatus []*TxVerifyResult `protobuf:"bytes,2,rep,name=verify_status,json=verifyStatus" json:"verify_status,omitempty"`
 }
 
 func (m *TransactionStatus) Reset()                    { *m = TransactionStatus{} }
 func (m *TransactionStatus) String() string            { return proto.CompactTextString(m) }
 func (*TransactionStatus) ProtoMessage()               {}
-func (*TransactionStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
+func (*TransactionStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
+
+func (m *TransactionStatus) GetVersion() uint64 {
+       if m != nil {
+               return m.Version
+       }
+       return 0
+}
 
-func (m *TransactionStatus) GetBitmap() []byte {
+func (m *TransactionStatus) GetVerifyStatus() []*TxVerifyResult {
        if m != nil {
-               return m.Bitmap
+               return m.VerifyStatus
        }
        return nil
 }
@@ -419,7 +444,7 @@ type Mux struct {
 func (m *Mux) Reset()                    { *m = Mux{} }
 func (m *Mux) String() string            { return proto.CompactTextString(m) }
 func (*Mux) ProtoMessage()               {}
-func (*Mux) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
+func (*Mux) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
 
 func (m *Mux) GetSources() []*ValueSource {
        if m != nil {
@@ -466,7 +491,7 @@ type Nonce struct {
 func (m *Nonce) Reset()                    { *m = Nonce{} }
 func (m *Nonce) String() string            { return proto.CompactTextString(m) }
 func (*Nonce) ProtoMessage()               {}
-func (*Nonce) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
+func (*Nonce) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
 
 func (m *Nonce) GetProgram() *Program {
        if m != nil {
@@ -504,7 +529,7 @@ type Coinbase struct {
 func (m *Coinbase) Reset()                    { *m = Coinbase{} }
 func (m *Coinbase) String() string            { return proto.CompactTextString(m) }
 func (*Coinbase) ProtoMessage()               {}
-func (*Coinbase) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
+func (*Coinbase) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
 
 func (m *Coinbase) GetWitnessDestination() *ValueDestination {
        if m != nil {
@@ -530,7 +555,7 @@ type Output struct {
 func (m *Output) Reset()                    { *m = Output{} }
 func (m *Output) String() string            { return proto.CompactTextString(m) }
 func (*Output) ProtoMessage()               {}
-func (*Output) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
+func (*Output) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
 
 func (m *Output) GetSource() *ValueSource {
        if m != nil {
@@ -569,7 +594,7 @@ type Retirement struct {
 func (m *Retirement) Reset()                    { *m = Retirement{} }
 func (m *Retirement) String() string            { return proto.CompactTextString(m) }
 func (*Retirement) ProtoMessage()               {}
-func (*Retirement) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
+func (*Retirement) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
 
 func (m *Retirement) GetSource() *ValueSource {
        if m != nil {
@@ -606,7 +631,7 @@ type Issuance struct {
 func (m *Issuance) Reset()                    { *m = Issuance{} }
 func (m *Issuance) String() string            { return proto.CompactTextString(m) }
 func (*Issuance) ProtoMessage()               {}
-func (*Issuance) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
+func (*Issuance) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
 
 func (m *Issuance) GetAnchorId() *Hash {
        if m != nil {
@@ -676,7 +701,7 @@ type Spend struct {
 func (m *Spend) Reset()                    { *m = Spend{} }
 func (m *Spend) String() string            { return proto.CompactTextString(m) }
 func (*Spend) ProtoMessage()               {}
-func (*Spend) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
+func (*Spend) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} }
 
 func (m *Spend) GetSpentOutputId() *Hash {
        if m != nil {
@@ -730,6 +755,7 @@ func init() {
        proto.RegisterType((*ValueDestination)(nil), "bc.ValueDestination")
        proto.RegisterType((*BlockHeader)(nil), "bc.BlockHeader")
        proto.RegisterType((*TxHeader)(nil), "bc.TxHeader")
+       proto.RegisterType((*TxVerifyResult)(nil), "bc.TxVerifyResult")
        proto.RegisterType((*TransactionStatus)(nil), "bc.TransactionStatus")
        proto.RegisterType((*Mux)(nil), "bc.Mux")
        proto.RegisterType((*Nonce)(nil), "bc.Nonce")
@@ -743,65 +769,68 @@ func init() {
 func init() { proto.RegisterFile("bc.proto", fileDescriptor0) }
 
 var fileDescriptor0 = []byte{
-       // 951 bytes of a gzipped FileDescriptorProto
-       0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x6e, 0xe3, 0x44,
-       0x14, 0x56, 0x62, 0x27, 0x76, 0x4e, 0x4a, 0xd3, 0x4c, 0xbb, 0x8b, 0xb5, 0x5a, 0xa4, 0xca, 0xa8,
-       0x74, 0xd1, 0x4a, 0x55, 0xb7, 0x5d, 0x10, 0x17, 0x5c, 0x50, 0x28, 0xb0, 0xb9, 0x28, 0xac, 0xa6,
-       0xab, 0xbd, 0xb5, 0xc6, 0xf6, 0x6c, 0x32, 0x22, 0xf1, 0x98, 0x99, 0x71, 0x28, 0x7d, 0x0e, 0x9e,
-       0x61, 0x1f, 0x82, 0xc7, 0xe2, 0x9a, 0x0b, 0x34, 0xe3, 0x71, 0xec, 0xfc, 0x94, 0x4d, 0x84, 0xb8,
-       0xf3, 0x39, 0x73, 0x7c, 0x7e, 0xbe, 0xf3, 0x7d, 0x1e, 0x83, 0x1f, 0x27, 0x67, 0xb9, 0xe0, 0x8a,
-       0xa3, 0x76, 0x9c, 0x84, 0x3f, 0x80, 0xfb, 0x8a, 0xc8, 0x09, 0xda, 0x87, 0xf6, 0xfc, 0x3c, 0x68,
-       0x1d, 0xb7, 0x9e, 0x75, 0x71, 0x7b, 0x7e, 0x6e, 0xec, 0x17, 0x41, 0xdb, 0xda, 0x2f, 0x8c, 0x7d,
-       0x11, 0x38, 0xd6, 0xbe, 0x30, 0xf6, 0x65, 0xe0, 0x5a, 0xfb, 0x32, 0xfc, 0x1a, 0xbc, 0xd7, 0x82,
-       0x8f, 0x05, 0x99, 0xa1, 0x4f, 0x00, 0xe6, 0xb3, 0x68, 0x4e, 0x85, 0x64, 0x3c, 0x33, 0x29, 0x5d,
-       0xdc, 0x9b, 0xcf, 0xde, 0x96, 0x0e, 0x84, 0xc0, 0x4d, 0x78, 0x4a, 0x4d, 0xee, 0x3d, 0x6c, 0x9e,
-       0xc3, 0x11, 0x78, 0x57, 0x52, 0x52, 0x35, 0xba, 0xfe, 0xcf, 0x8d, 0xdc, 0x40, 0xdf, 0xa4, 0xba,
-       0x9a, 0xf1, 0x22, 0x53, 0xe8, 0x33, 0xf0, 0x89, 0x36, 0x23, 0x96, 0x9a, 0xa4, 0xfd, 0x8b, 0xfe,
-       0x59, 0x9c, 0x9c, 0xd9, 0x6a, 0xd8, 0x33, 0x87, 0xa3, 0x14, 0x3d, 0x86, 0x2e, 0x31, 0x6f, 0x98,
-       0x52, 0x2e, 0xb6, 0x56, 0x38, 0x86, 0x81, 0x89, 0xbd, 0xa6, 0xef, 0x58, 0xc6, 0x94, 0x1e, 0xe0,
-       0x4b, 0x38, 0x60, 0x52, 0x16, 0x24, 0x4b, 0x68, 0x94, 0x97, 0x33, 0x37, 0x53, 0x5b, 0x18, 0xf0,
-       0xa0, 0x0a, 0xaa, 0x70, 0x79, 0x0a, 0x6e, 0x4a, 0x14, 0x31, 0x05, 0xfa, 0x17, 0xbe, 0x8e, 0xd5,
-       0xd0, 0x63, 0xe3, 0x0d, 0xa7, 0xd0, 0x7f, 0x4b, 0xa6, 0x05, 0xbd, 0xe5, 0x85, 0x48, 0x28, 0x7a,
-       0x02, 0x8e, 0xa0, 0xef, 0x6c, 0xde, 0x3a, 0x56, 0x3b, 0xd1, 0x09, 0x74, 0xe6, 0x3a, 0xd4, 0x66,
-       0x1a, 0x2c, 0x06, 0x2a, 0x67, 0xc6, 0xe5, 0x29, 0x7a, 0x02, 0x7e, 0xce, 0xa5, 0xe9, 0xd9, 0xe0,
-       0xe5, 0xe2, 0x85, 0x1d, 0xfe, 0x0a, 0x07, 0xa6, 0xda, 0x35, 0x95, 0x8a, 0x65, 0xc4, 0xcc, 0xf5,
-       0x3f, 0x97, 0xfc, 0xbb, 0x0d, 0xfd, 0x6f, 0xa7, 0x3c, 0xf9, 0xe5, 0x15, 0x25, 0x29, 0x15, 0x28,
-       0x00, 0x6f, 0x99, 0x23, 0x95, 0xa9, 0x77, 0x31, 0xa1, 0x6c, 0x3c, 0x59, 0xec, 0xa2, 0xb4, 0xd0,
-       0x4b, 0x18, 0xe6, 0x82, 0xce, 0x19, 0x2f, 0x64, 0x14, 0xeb, 0x4c, 0x7a, 0xa9, 0xce, 0x4a, 0xbb,
-       0x83, 0x2a, 0xc4, 0xd4, 0x1a, 0xa5, 0xe8, 0x29, 0xf4, 0x14, 0x9b, 0x51, 0xa9, 0xc8, 0x2c, 0x37,
-       0x3c, 0x71, 0x71, 0xed, 0x40, 0x5f, 0xc0, 0x50, 0x09, 0x92, 0x49, 0x92, 0xe8, 0x26, 0x65, 0x24,
-       0x38, 0x57, 0x41, 0x67, 0x25, 0xe7, 0x41, 0x33, 0x04, 0x73, 0xae, 0xd0, 0x37, 0xf0, 0x71, 0xc3,
-       0x17, 0x49, 0x45, 0x54, 0x21, 0xa3, 0x09, 0x91, 0x93, 0xa0, 0xbb, 0xf2, 0xf2, 0xa3, 0x46, 0xe0,
-       0xad, 0x89, 0x33, 0x82, 0x3b, 0x82, 0x4e, 0xc6, 0xb3, 0x84, 0x06, 0x9e, 0x69, 0xa9, 0x34, 0xb4,
-       0x38, 0x62, 0xa6, 0x64, 0xe0, 0x1b, 0xa7, 0x79, 0x46, 0xd7, 0x80, 0xd6, 0x6b, 0x05, 0x3d, 0x53,
-       0xe6, 0x91, 0x2e, 0xf3, 0x66, 0xb5, 0x00, 0x1e, 0xae, 0xd5, 0x0c, 0xff, 0x6c, 0x81, 0xff, 0xe6,
-       0xee, 0x83, 0xd8, 0x9f, 0xc2, 0x40, 0x52, 0xc1, 0xc8, 0x94, 0xdd, 0xd3, 0x34, 0x92, 0xec, 0x9e,
-       0xda, 0x25, 0xec, 0xd7, 0xee, 0x5b, 0x76, 0x4f, 0xb5, 0xca, 0x35, 0x8a, 0x91, 0x20, 0xd9, 0x98,
-       0xda, 0x65, 0x1b, 0x5c, 0xb1, 0x76, 0xa0, 0x53, 0x00, 0x41, 0x65, 0x31, 0xd5, 0xc2, 0x93, 0x81,
-       0x7b, 0xec, 0x2c, 0x61, 0xd2, 0x2b, 0xcf, 0x46, 0xa9, 0x44, 0x9f, 0x82, 0x4f, 0xef, 0x54, 0x09,
-       0xdd, 0x2a, 0xee, 0x1e, 0xbd, 0x53, 0xfa, 0x21, 0x7c, 0x0e, 0xc3, 0xb5, 0x21, 0x35, 0x4d, 0x62,
-       0xa6, 0x66, 0x24, 0x37, 0x33, 0xec, 0x61, 0x6b, 0x85, 0x7f, 0xb5, 0xc0, 0xb9, 0x29, 0xee, 0xd0,
-       0xe7, 0xe0, 0x49, 0x23, 0x26, 0x19, 0xb4, 0x4c, 0x7d, 0xc3, 0xda, 0x86, 0xc8, 0x70, 0x75, 0x8e,
-       0x4e, 0xc0, 0xab, 0x94, 0xdc, 0x5e, 0x57, 0x72, 0x75, 0xb6, 0xd4, 0xab, 0xf3, 0x40, 0xaf, 0xe8,
-       0x47, 0x38, 0xfa, 0x8d, 0xa9, 0x8c, 0x4a, 0x19, 0xa5, 0xb5, 0xba, 0x2a, 0x0c, 0x8e, 0x16, 0x3d,
-       0x34, 0xa4, 0x87, 0x0f, 0xed, 0x1b, 0x0d, 0x9f, 0x44, 0xcf, 0x61, 0x58, 0x25, 0x22, 0x62, 0x5c,
-       0xcc, 0x68, 0xa6, 0x64, 0xd0, 0x39, 0x76, 0x9e, 0xed, 0xe1, 0x03, 0x7b, 0x70, 0x55, 0xf9, 0xf5,
-       0x7a, 0x3b, 0x3f, 0x19, 0x0a, 0x35, 0x66, 0x69, 0x6d, 0x39, 0x4b, 0xfb, 0xa1, 0x59, 0x36, 0xb6,
-       0xe0, 0x6c, 0x6e, 0x01, 0x7d, 0x05, 0x87, 0x8b, 0xe0, 0x2c, 0x99, 0x70, 0x41, 0x53, 0x2d, 0x50,
-       0x77, 0x25, 0x79, 0x95, 0xf1, 0xca, 0xc6, 0x8c, 0xd2, 0x90, 0x83, 0xff, 0x1d, 0x67, 0x59, 0x4c,
-       0x24, 0x45, 0xdf, 0xd7, 0x59, 0x1a, 0xf0, 0xd9, 0x51, 0x36, 0xa3, 0x87, 0xd6, 0xd1, 0xd3, 0xaa,
-       0x27, 0x22, 0x66, 0x4a, 0x10, 0xf1, 0xbb, 0xbd, 0x6a, 0x6a, 0x47, 0xf8, 0xbe, 0x05, 0xdd, 0x9f,
-       0x0b, 0x95, 0x17, 0x0a, 0x9d, 0x42, 0xb7, 0x64, 0x81, 0x2d, 0xb1, 0x46, 0x12, 0x7b, 0x8c, 0x5e,
-       0xc2, 0x20, 0xe1, 0x99, 0x12, 0x7c, 0x1a, 0xfd, 0x0b, 0x57, 0xf6, 0x6d, 0xcc, 0xeb, 0x5d, 0x28,
-       0x13, 0x80, 0xc7, 0x45, 0xca, 0x32, 0x32, 0xb5, 0x1f, 0xa8, 0xca, 0x0c, 0x15, 0x00, 0xa6, 0x8a,
-       0x09, 0xaa, 0x21, 0xde, 0xbe, 0xd7, 0xad, 0x96, 0xdb, 0xa8, 0xea, 0x2c, 0x57, 0xfd, 0xc3, 0x01,
-       0x7f, 0x64, 0x6f, 0x2f, 0x74, 0x02, 0xbd, 0x72, 0x9d, 0xf5, 0x15, 0x5a, 0x27, 0xf3, 0xcb, 0xa3,
-       0x51, 0xba, 0xed, 0x0d, 0xb1, 0x15, 0x1e, 0x0f, 0x70, 0xc0, 0xdd, 0x91, 0x03, 0x37, 0x10, 0x2c,
-       0x08, 0x69, 0xfe, 0x01, 0xd2, 0xc5, 0x25, 0x6e, 0x3f, 0x35, 0x87, 0x8b, 0x2e, 0xeb, 0xfb, 0x1d,
-       0x3f, 0xae, 0x08, 0xba, 0x72, 0xef, 0x6f, 0x14, 0x43, 0x77, 0x37, 0x31, 0x78, 0x1f, 0x14, 0x43,
-       0x73, 0x2d, 0xfe, 0xf2, 0x5a, 0xde, 0xb7, 0xa1, 0x73, 0x9b, 0xd3, 0x2c, 0x45, 0xe7, 0x30, 0x90,
-       0x39, 0xcd, 0x54, 0xc4, 0x0d, 0x89, 0x37, 0x6d, 0xe6, 0x23, 0x13, 0x50, 0x92, 0x7c, 0x94, 0x6e,
-       0xc7, 0x88, 0x07, 0x70, 0x77, 0x76, 0xc4, 0x7d, 0x23, 0x50, 0xee, 0x6e, 0x40, 0x75, 0x76, 0x02,
-       0xaa, 0xbb, 0x04, 0x54, 0xdc, 0x35, 0xff, 0xb7, 0x97, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xeb,
-       0x55, 0xfc, 0x14, 0xeb, 0x0a, 0x00, 0x00,
+       // 994 bytes of a gzipped FileDescriptorProto
+       0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcb, 0x6e, 0xdb, 0x46,
+       0x17, 0x86, 0x44, 0x4a, 0xa2, 0x8f, 0x1c, 0xcb, 0x1e, 0x3b, 0xf9, 0x89, 0x20, 0x3f, 0x6a, 0xb0,
+       0x70, 0x9d, 0xa2, 0x80, 0xe1, 0x4b, 0x7a, 0x59, 0x74, 0x51, 0xb7, 0x6e, 0x1a, 0x2d, 0xdc, 0x06,
+       0x63, 0xc3, 0x5b, 0x62, 0x44, 0x8e, 0xad, 0x41, 0x25, 0x8e, 0x3a, 0x33, 0x54, 0x1d, 0x3f, 0x47,
+       0x9f, 0x21, 0x0f, 0xd1, 0xc7, 0xea, 0xba, 0x8b, 0x62, 0x0e, 0x87, 0x12, 0x75, 0x71, 0x22, 0xa1,
+       0xe8, 0x8e, 0xe7, 0x32, 0xe7, 0xf2, 0x9d, 0xef, 0x0c, 0x07, 0x82, 0x5e, 0x72, 0x34, 0x52, 0xd2,
+       0x48, 0x52, 0xef, 0x25, 0xd1, 0x6b, 0xf0, 0xdf, 0x30, 0xdd, 0x27, 0x5b, 0x50, 0x1f, 0x1f, 0x87,
+       0xb5, 0xfd, 0xda, 0xcb, 0x26, 0xad, 0x8f, 0x8f, 0x51, 0x3e, 0x09, 0xeb, 0x4e, 0x3e, 0x41, 0xf9,
+       0x34, 0xf4, 0x9c, 0x7c, 0x8a, 0xf2, 0x59, 0xe8, 0x3b, 0xf9, 0x2c, 0xfa, 0x16, 0x5a, 0x6f, 0x95,
+       0xbc, 0x53, 0x6c, 0x48, 0xfe, 0x0f, 0x30, 0x1e, 0xc6, 0x63, 0xae, 0xb4, 0x90, 0x19, 0x86, 0xf4,
+       0xe9, 0xc6, 0x78, 0x78, 0x53, 0x28, 0x08, 0x01, 0x3f, 0x91, 0x29, 0xc7, 0xd8, 0x9b, 0x14, 0xbf,
+       0xa3, 0x2e, 0xb4, 0xce, 0xb5, 0xe6, 0xa6, 0x7b, 0xf1, 0xaf, 0x0b, 0xb9, 0x84, 0x36, 0x86, 0x3a,
+       0x1f, 0xca, 0x3c, 0x33, 0xe4, 0x33, 0x08, 0x98, 0x15, 0x63, 0x91, 0x62, 0xd0, 0xf6, 0x69, 0xfb,
+       0xa8, 0x97, 0x1c, 0xb9, 0x6c, 0xb4, 0x85, 0xc6, 0x6e, 0x4a, 0x9e, 0x41, 0x93, 0xe1, 0x09, 0x4c,
+       0xe5, 0x53, 0x27, 0x45, 0x77, 0xd0, 0x41, 0xdf, 0x0b, 0x7e, 0x2b, 0x32, 0x61, 0x6c, 0x03, 0x5f,
+       0xc1, 0xb6, 0xd0, 0x3a, 0x67, 0x59, 0xc2, 0xe3, 0x51, 0xd1, 0x73, 0x35, 0xb4, 0x83, 0x81, 0x76,
+       0x4a, 0xa7, 0x12, 0x97, 0x17, 0xe0, 0xa7, 0xcc, 0x30, 0x4c, 0xd0, 0x3e, 0x0d, 0xac, 0xaf, 0x85,
+       0x9e, 0xa2, 0x36, 0x1a, 0x40, 0xfb, 0x86, 0x0d, 0x72, 0x7e, 0x25, 0x73, 0x95, 0x70, 0xf2, 0x1c,
+       0x3c, 0xc5, 0x6f, 0x5d, 0xdc, 0xa9, 0xaf, 0x55, 0x92, 0x03, 0x68, 0x8c, 0xad, 0xab, 0x8b, 0xd4,
+       0x99, 0x34, 0x54, 0xf4, 0x4c, 0x0b, 0x2b, 0x79, 0x0e, 0xc1, 0x48, 0x6a, 0xac, 0x19, 0xf1, 0xf2,
+       0xe9, 0x44, 0x8e, 0x7e, 0x83, 0x6d, 0xcc, 0x76, 0xc1, 0xb5, 0x11, 0x19, 0xc3, 0xbe, 0xfe, 0xe3,
+       0x94, 0x7f, 0xd7, 0xa1, 0xfd, 0xfd, 0x40, 0x26, 0xbf, 0xbe, 0xe1, 0x2c, 0xe5, 0x8a, 0x84, 0xd0,
+       0x9a, 0xe5, 0x48, 0x29, 0xda, 0x59, 0xf4, 0xb9, 0xb8, 0xeb, 0x4f, 0x66, 0x51, 0x48, 0xe4, 0x15,
+       0xec, 0x8c, 0x14, 0x1f, 0x0b, 0x99, 0xeb, 0xb8, 0x67, 0x23, 0xd9, 0xa1, 0x7a, 0x73, 0xe5, 0x76,
+       0x4a, 0x17, 0xcc, 0xd5, 0x4d, 0xc9, 0x0b, 0xd8, 0x30, 0x62, 0xc8, 0xb5, 0x61, 0xc3, 0x11, 0xf2,
+       0xc4, 0xa7, 0x53, 0x05, 0xf9, 0x12, 0x76, 0x8c, 0x62, 0x99, 0x66, 0x89, 0x2d, 0x52, 0xc7, 0x4a,
+       0x4a, 0x13, 0x36, 0xe6, 0x62, 0x6e, 0x57, 0x5d, 0xa8, 0x94, 0x86, 0x7c, 0x07, 0xff, 0xab, 0xe8,
+       0x62, 0x6d, 0x98, 0xc9, 0x75, 0xdc, 0x67, 0xba, 0x1f, 0x36, 0xe7, 0x0e, 0x3f, 0xad, 0x38, 0x5e,
+       0xa1, 0x1f, 0x2e, 0xdc, 0x1e, 0x34, 0x32, 0x99, 0x25, 0x3c, 0x6c, 0x61, 0x49, 0x85, 0x60, 0x97,
+       0xa3, 0x27, 0x8c, 0x0e, 0x03, 0x54, 0xe2, 0x37, 0xb9, 0x00, 0xb2, 0x98, 0x2b, 0xdc, 0xc0, 0x34,
+       0x4f, 0x6d, 0x9a, 0xeb, 0xf9, 0x04, 0x74, 0x67, 0x21, 0x67, 0xf4, 0x67, 0x0d, 0x82, 0xeb, 0xfb,
+       0x8f, 0x62, 0x7f, 0x08, 0x1d, 0xcd, 0x95, 0x60, 0x03, 0xf1, 0xc0, 0xd3, 0x58, 0x8b, 0x07, 0xee,
+       0x86, 0xb0, 0x35, 0x55, 0x5f, 0x89, 0x07, 0x6e, 0xb7, 0xdc, 0xa2, 0x18, 0x2b, 0x96, 0xdd, 0x71,
+       0x37, 0x6c, 0xc4, 0x95, 0x5a, 0x05, 0x39, 0x04, 0x50, 0x5c, 0xe7, 0x03, 0xbb, 0x78, 0x3a, 0xf4,
+       0xf7, 0xbd, 0x19, 0x4c, 0x36, 0x0a, 0x5b, 0x37, 0xd5, 0xe4, 0x53, 0x08, 0xf8, 0xbd, 0x29, 0xa0,
+       0x9b, 0xc7, 0xbd, 0xc5, 0xef, 0x8d, 0xfd, 0x88, 0x4e, 0x60, 0xeb, 0xfa, 0xfe, 0x86, 0x2b, 0x71,
+       0xfb, 0x8e, 0xe2, 0x49, 0xf2, 0x09, 0xb4, 0x1d, 0xe8, 0xb7, 0x4c, 0x0c, 0xb0, 0x8b, 0x80, 0x42,
+       0xa1, 0x7a, 0xcd, 0xc4, 0x20, 0xba, 0x85, 0x9d, 0x05, 0x5c, 0x3e, 0xd0, 0xf7, 0xd7, 0xf0, 0x64,
+       0x8c, 0xf1, 0x4b, 0x7c, 0xeb, 0x58, 0x32, 0x41, 0x7c, 0x67, 0x52, 0xd3, 0xcd, 0xc2, 0xd1, 0xe1,
+       0xfa, 0x57, 0x0d, 0xbc, 0xcb, 0xfc, 0x9e, 0x7c, 0x0e, 0x2d, 0x8d, 0xab, 0xab, 0xc3, 0x1a, 0x1e,
+       0xc5, 0x1d, 0xa9, 0xac, 0x34, 0x2d, 0xed, 0xe4, 0x00, 0x5a, 0xe5, 0xbd, 0x51, 0x5f, 0xbc, 0x37,
+       0x4a, 0xdb, 0x0c, 0x32, 0xde, 0x23, 0xc8, 0x90, 0x9f, 0x60, 0xef, 0x77, 0x61, 0x32, 0xae, 0x75,
+       0x9c, 0x4e, 0x77, 0xb9, 0x44, 0x7c, 0x6f, 0x52, 0x43, 0x65, 0xd1, 0xe9, 0xae, 0x3b, 0x51, 0xd1,
+       0x69, 0xf2, 0x05, 0xec, 0x94, 0x81, 0x98, 0xba, 0xcb, 0x87, 0x3c, 0x33, 0x3a, 0x6c, 0xec, 0x7b,
+       0x2f, 0x37, 0xe9, 0xb6, 0x33, 0x9c, 0x97, 0x7a, 0x4b, 0xa6, 0xc6, 0xcf, 0x48, 0xd8, 0x4a, 0x2f,
+       0xb5, 0x15, 0x7b, 0xa9, 0x3f, 0xd6, 0xcb, 0xd2, 0x12, 0xbc, 0xe5, 0x25, 0x90, 0x6f, 0x60, 0x77,
+       0xe2, 0x9c, 0x25, 0x7d, 0xa9, 0x78, 0x6a, 0xaf, 0x03, 0x7f, 0x2e, 0x78, 0x19, 0xf1, 0xdc, 0xf9,
+       0x74, 0xd3, 0x48, 0x42, 0xf0, 0x83, 0x14, 0x59, 0x8f, 0x69, 0x4e, 0x7e, 0x9c, 0x46, 0xa9, 0xc0,
+       0xe7, 0x5a, 0x59, 0x8e, 0x1e, 0x59, 0x44, 0xcf, 0xde, 0x31, 0x4c, 0xf5, 0x84, 0x51, 0x4c, 0xbd,
+       0x73, 0x3f, 0xb6, 0xa9, 0x22, 0x7a, 0x5f, 0x83, 0xe6, 0x2f, 0xb9, 0x19, 0xe5, 0x86, 0x1c, 0x42,
+       0xb3, 0x60, 0x81, 0x4b, 0xb1, 0x40, 0x12, 0x67, 0x26, 0xaf, 0xa0, 0x93, 0xc8, 0xcc, 0x28, 0x39,
+       0x88, 0x3f, 0xc0, 0x95, 0x2d, 0xe7, 0xf3, 0x76, 0x1d, 0xca, 0x84, 0xd0, 0x92, 0x2a, 0x15, 0x19,
+       0x1b, 0xb8, 0xeb, 0xb0, 0x14, 0x23, 0x03, 0x40, 0xb9, 0x11, 0x8a, 0x5b, 0x88, 0x57, 0xaf, 0x75,
+       0xa5, 0xe1, 0x56, 0xb2, 0x7a, 0xb3, 0x59, 0xff, 0xf0, 0x20, 0xe8, 0xba, 0x7f, 0x25, 0x39, 0x80,
+       0x8d, 0x62, 0x9c, 0xd3, 0x1f, 0xf6, 0x34, 0x58, 0x50, 0x98, 0xba, 0xe9, 0xaa, 0xff, 0xa3, 0x95,
+       0xf0, 0x78, 0x84, 0x03, 0xfe, 0x9a, 0x1c, 0xb8, 0x84, 0x70, 0x42, 0x48, 0x7c, 0x71, 0xa4, 0x93,
+       0x27, 0x83, 0xbb, 0xd8, 0x76, 0x27, 0x55, 0x4e, 0x5f, 0x13, 0xf4, 0x59, 0x49, 0xd0, 0xb9, 0x57,
+       0xc6, 0xd2, 0x65, 0x68, 0xae, 0xb7, 0x0c, 0xad, 0x8f, 0x2e, 0x43, 0x75, 0x2c, 0xc1, 0xec, 0x58,
+       0xde, 0xd7, 0xa1, 0x71, 0x35, 0xe2, 0x59, 0x4a, 0x8e, 0xa1, 0xa3, 0x47, 0x3c, 0x33, 0xb1, 0x44,
+       0x12, 0x2f, 0x9b, 0xcc, 0x13, 0x74, 0x28, 0x48, 0xde, 0x4d, 0x57, 0x63, 0xc4, 0x23, 0xb8, 0x7b,
+       0x6b, 0xe2, 0xbe, 0x14, 0x28, 0x7f, 0x3d, 0xa0, 0x1a, 0x6b, 0x01, 0xd5, 0x9c, 0x01, 0xaa, 0xd7,
+       0xc4, 0xd7, 0xf4, 0xd9, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, 0x5c, 0x72, 0x59, 0x0b,
+       0x00, 0x00,
 }
index e67fe51..dfd2cb4 100644 (file)
@@ -68,8 +68,13 @@ message TxHeader {
   Hash          ext_hash        = 5;
 }
 
+message TxVerifyResult {
+  bool status_fail = 1;
+}
+
 message TransactionStatus {
-  bytes bitmap = 1;
+  uint64                  version        = 1;
+  repeated TxVerifyResult verify_status  = 2;
 }
 
 message Mux {
index 7999454..900151c 100644 (file)
@@ -1,6 +1,7 @@
 package bc
 
 import (
+       "io"
        "math"
 
        "github.com/bytom/crypto/sha3pool"
@@ -11,30 +12,32 @@ var (
        interiorPrefix = []byte{0x01}
 )
 
-// MerkleRoot creates a merkle tree from a slice of transactions
-// and returns the root hash of the tree.
-func MerkleRoot(transactions []*Tx) (root Hash, err error) {
+type merkleNode interface {
+       WriteTo(io.Writer) (int64, error)
+}
+
+func merkleRoot(nodes []merkleNode) (root Hash, err error) {
        switch {
-       case len(transactions) == 0:
+       case len(nodes) == 0:
                return EmptyStringHash, nil
 
-       case len(transactions) == 1:
+       case len(nodes) == 1:
                h := sha3pool.Get256()
                defer sha3pool.Put256(h)
 
                h.Write(leafPrefix)
-               transactions[0].ID.WriteTo(h)
+               nodes[0].WriteTo(h)
                root.ReadFrom(h)
                return root, nil
 
        default:
-               k := prevPowerOfTwo(len(transactions))
-               left, err := MerkleRoot(transactions[:k])
+               k := prevPowerOfTwo(len(nodes))
+               left, err := merkleRoot(nodes[:k])
                if err != nil {
                        return root, err
                }
 
-               right, err := MerkleRoot(transactions[k:])
+               right, err := merkleRoot(nodes[k:])
                if err != nil {
                        return root, err
                }
@@ -49,6 +52,25 @@ func MerkleRoot(transactions []*Tx) (root Hash, err error) {
        }
 }
 
+// TxMerkleRoot creates a merkle tree from a slice of TxVerifyResult
+func TxStatusMerkleRoot(tvrs []*TxVerifyResult) (root Hash, err error) {
+       nodes := []merkleNode{}
+       for _, tvr := range tvrs {
+               nodes = append(nodes, tvr)
+       }
+       return merkleRoot(nodes)
+}
+
+// TxMerkleRoot creates a merkle tree from a slice of transactions
+// and returns the root hash of the tree.
+func TxMerkleRoot(transactions []*Tx) (root Hash, err error) {
+       nodes := []merkleNode{}
+       for _, tx := range transactions {
+               nodes = append(nodes, tx.ID)
+       }
+       return merkleRoot(nodes)
+}
+
 // prevPowerOfTwo returns the largest power of two that is smaller than a given number.
 // In other words, for some input n, the prevPowerOfTwo k is a power of two such that
 // k < n <= 2k. This is a helper function used during the calculation of a merkle tree.
index 40ad650..2f2a609 100644 (file)
@@ -67,7 +67,7 @@ func TestMerkleRoot(t *testing.T) {
                                },
                        }).Tx)
                }
-               got, err := MerkleRoot(txs)
+               got, err := TxMerkleRoot(txs)
                if err != nil {
                        t.Fatalf("unexpected error %s", err)
                }
@@ -93,14 +93,14 @@ func TestDuplicateLeaves(t *testing.T) {
 
        // first, get the root of an unbalanced tree
        txns := []*Tx{txs[5], txs[4], txs[3], txs[2], txs[1], txs[0]}
-       root1, err := MerkleRoot(txns)
+       root1, err := TxMerkleRoot(txns)
        if err != nil {
                t.Fatalf("unexpected error %s", err)
        }
 
        // now, get the root of a balanced tree that repeats leaves 0 and 1
        txns = []*Tx{txs[5], txs[4], txs[3], txs[2], txs[1], txs[0], txs[1], txs[0]}
-       root2, err := MerkleRoot(txns)
+       root2, err := TxMerkleRoot(txns)
        if err != nil {
                t.Fatalf("unexpected error %s", err)
        }
@@ -125,14 +125,14 @@ func TestAllDuplicateLeaves(t *testing.T) {
 
        // first, get the root of an unbalanced tree
        txs := []*Tx{tx6, tx5, tx4, tx3, tx2, tx1}
-       root1, err := MerkleRoot(txs)
+       root1, err := TxMerkleRoot(txs)
        if err != nil {
                t.Fatalf("unexpected error %s", err)
        }
 
        // now, get the root of a balanced tree that repeats leaves 5 and 6
        txs = []*Tx{tx6, tx5, tx6, tx5, tx4, tx3, tx2, tx1}
-       root2, err := MerkleRoot(txs)
+       root2, err := TxMerkleRoot(txs)
        if err != nil {
                t.Fatalf("unexpected error %s", err)
        }
index cc1ae5c..743bfe4 100644 (file)
@@ -1,72 +1,49 @@
 package bc
 
 import (
+       "encoding/json"
        "errors"
        "io"
-
-       "github.com/bytom/encoding/blockchain"
 )
 
 const (
-       maxBitmapSize = 8388608
-       bitsPerByte   = 8
+       TransactionStatusVersion = 1
 )
 
-var errOverRange = errors.New("bitmap range exceed the limit")
-var errBadRange = errors.New("bitmap get a unexisted bit")
-
 func NewTransactionStatus() *TransactionStatus {
        return &TransactionStatus{
-               Bitmap: []byte{0},
+               Version:      TransactionStatusVersion,
+               VerifyStatus: []*TxVerifyResult{},
        }
 }
 
-func (TransactionStatus) typ() string {
-       return "transaction_status"
-}
-
-func (ts *TransactionStatus) writeForHash(w io.Writer) {
-       mustWriteForHash(w, ts.Bitmap)
-}
-
 func (ts *TransactionStatus) SetStatus(i int, gasOnly bool) error {
-       if i >= maxBitmapSize {
-               return errOverRange
+       if i > len(ts.VerifyStatus) {
+               return errors.New("setStatus should be set one by one")
        }
 
-       index, pos := i/bitsPerByte, i%bitsPerByte
-       for len(ts.Bitmap) < index+1 {
-               ts.Bitmap = append(ts.Bitmap, 0)
-       }
-
-       if gasOnly {
-               ts.Bitmap[index] |= 0x01 << uint8(pos)
+       if i == len(ts.VerifyStatus) {
+               ts.VerifyStatus = append(ts.VerifyStatus, &TxVerifyResult{StatusFail: gasOnly})
        } else {
-               ts.Bitmap[index] &^= 0x01 << uint8(pos)
+               ts.VerifyStatus[i].StatusFail = gasOnly
        }
        return nil
 }
 
 func (ts *TransactionStatus) GetStatus(i int) (bool, error) {
-       if i >= maxBitmapSize {
-               return false, errOverRange
-       }
-
-       index, pos := i/bitsPerByte, i%bitsPerByte
-       for len(ts.Bitmap) < index+1 {
-               return false, errBadRange
+       if i >= len(ts.VerifyStatus) {
+               return false, errors.New("GetStatus is out of range")
        }
 
-       result := (ts.Bitmap[index] >> uint8(pos)) & 0x01
-       return result == 1, nil
+       return ts.VerifyStatus[i].StatusFail, nil
 }
 
-func (ts *TransactionStatus) ReadFrom(r *blockchain.Reader) (err error) {
-       ts.Bitmap, err = blockchain.ReadVarstr31(r)
-       return err
-}
+func (tvr *TxVerifyResult) WriteTo(w io.Writer) (int64, error) {
+       bytes, err := json.Marshal(tvr)
+       if err != nil {
+               return 0, err
+       }
 
-func (ts *TransactionStatus) WriteTo(w io.Writer) error {
-       _, err := blockchain.WriteVarstr31(w, ts.Bitmap)
-       return err
+       n, err := w.Write(bytes)
+       return int64(n), err
 }
index 2aab128..6089d84 100644 (file)
@@ -23,6 +23,7 @@ func TestSetBits(t *testing.T) {
                },
                {
                        op: map[int]bool{
+                               0: false,
                                1: true,
                        },
                        result: []bool{false, true},
@@ -36,30 +37,6 @@ func TestSetBits(t *testing.T) {
                },
                {
                        op: map[int]bool{
-                               7: true,
-                       },
-                       result: []bool{false, false, false, false, false, false, false, true},
-               },
-               {
-                       op: map[int]bool{
-                               7: false,
-                       },
-                       result: []bool{false, false, false, false, false, false, false, false},
-               },
-               {
-                       op: map[int]bool{
-                               8: true,
-                       },
-                       result: []bool{false, false, false, false, false, false, false, false, true},
-               },
-               {
-                       op: map[int]bool{
-                               8: false,
-                       },
-                       result: []bool{false, false, false, false, false, false, false, false, false},
-               },
-               {
-                       op: map[int]bool{
                                0: true,
                                1: false,
                                2: false,
@@ -77,23 +54,20 @@ func TestSetBits(t *testing.T) {
 
        for ci, c := range cases {
                ts := NewTransactionStatus()
-               for k, v := range c.op {
-                       if err := ts.SetStatus(k, v); err != nil {
-                               t.Error(err)
+               for i := 0; i < len(c.op); i++ {
+                       if err := ts.SetStatus(i, c.op[i]); err != nil {
+                               t.Errorf("test case #%d, %t", ci, err)
                        }
                }
 
                for i, v := range c.result {
                        result, err := ts.GetStatus(i)
                        if err != nil {
-                               t.Error(err)
+                               t.Errorf("test case #%d, %t", ci, err)
                        }
                        if result != v {
                                t.Errorf("bad result, %d want %t get %t", i, v, result)
                        }
                }
-               if len(ts.Bitmap) != (len(c.result)+7)/bitsPerByte {
-                       t.Errorf("wrong bitmap size, %d want %d get %d", ci, len(c.result)/bitsPerByte+1, len(ts.Bitmap))
-               }
        }
 }
index 3780ab3..97afcb6 100644 (file)
@@ -156,7 +156,7 @@ func TestApplyBlock(t *testing.T) {
        }
 
        for i, c := range cases {
-
+               c.block.TransactionStatus.SetStatus(0, false)
                if err := c.inputView.ApplyBlock(c.block, c.block.TransactionStatus); c.err != (err != nil) {
                        t.Errorf("want err = %v, get err = %v", c.err, err)
                }
@@ -257,6 +257,7 @@ func TestDetachBlock(t *testing.T) {
        }
 
        for i, c := range cases {
+               c.block.TransactionStatus.SetStatus(0, false)
                if err := c.inputView.DetachBlock(c.block, c.block.TransactionStatus); c.err != (err != nil) {
                        t.Errorf("case %d want err = %v, get err = %v", i, c.err, err)
                }
index e9cd96a..b50ef96 100644 (file)
@@ -23,7 +23,7 @@ func generate(tb testing.TB, prev *bc.Block) *bc.Block {
        }
 
        var err error
-       b.TransactionsMerkleRoot, err = bc.MerkleRoot(nil)
+       b.TransactionsMerkleRoot, err = bc.TxMerkleRoot(nil)
        if err != nil {
                tb.Fatal(err)
        }
index 5567bcf..b5b60c0 100644 (file)
@@ -599,7 +599,7 @@ func ValidateBlock(b, prev *bc.Block, seed *bc.Hash, store database.Store) error
                return err
        }
 
-       txRoot, err := bc.MerkleRoot(b.Transactions)
+       txRoot, err := bc.TxMerkleRoot(b.Transactions)
        if err != nil {
                return errors.Wrap(err, "computing transaction merkle root")
        }
@@ -608,7 +608,12 @@ func ValidateBlock(b, prev *bc.Block, seed *bc.Hash, store database.Store) error
                return errors.WithDetailf(errMismatchedMerkleRoot, "computed %x, current block wants %x", txRoot.Bytes(), b.TransactionsRoot.Bytes())
        }
 
-       if bc.EntryID(b.TransactionStatus) != *b.TransactionStatusHash {
+       txStatusHash, err := bc.TxStatusMerkleRoot(b.TransactionStatus.VerifyStatus)
+       if err != nil {
+               return err
+       }
+
+       if txStatusHash != *b.TransactionStatusHash {
                return errMismatchedTxStatus
        }
        return nil
index 182db3a..3f839ad 100644 (file)
@@ -434,14 +434,19 @@ func TestValidateBlock(t *testing.T) {
        }
 
        txStatus := bc.NewTransactionStatus()
-       txStatusHash := bc.EntryID(txStatus)
+       txStatus.SetStatus(0, false)
+       txStatusHash, err := bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
+       if err != nil {
+               t.Error(err)
+       }
 
        for _, c := range cases {
-               txRoot, err := bc.MerkleRoot(c.block.Transactions)
+               txRoot, err := bc.TxMerkleRoot(c.block.Transactions)
                if err != nil {
                        t.Errorf("computing transaction merkle root error: %v", err)
                        continue
                }
+
                c.block.BlockHeader.TransactionStatus = bc.NewTransactionStatus()
                c.block.TransactionsRoot = &txRoot
                c.block.TransactionStatusHash = &txStatusHash