@@ -36,11 +36,8 @@ use crate::{
36
36
DataRequestError , EpochCalculationError , OutputPointerParseError , Secp256k1ConversionError ,
37
37
TransactionError ,
38
38
} ,
39
- get_environment,
40
- proto:: {
41
- versioning:: { ProtocolVersion , VersionedHashable } ,
42
- ProtobufConvert ,
43
- } ,
39
+ get_environment, get_protocol_version,
40
+ proto:: { versioning:: Versioned , ProtobufConvert } ,
44
41
superblock:: SuperBlockState ,
45
42
transaction:: {
46
43
CommitTransaction , DRTransaction , DRTransactionBody , Memoized , MintTransaction ,
@@ -536,7 +533,7 @@ impl Block {
536
533
}
537
534
538
535
pub fn is_genesis ( & self , genesis : & Hash ) -> bool {
539
- self . versioned_hash ( ProtocolVersion :: Legacy ) . eq ( genesis)
536
+ self . hash ( ) . eq ( genesis)
540
537
}
541
538
}
542
539
@@ -671,7 +668,9 @@ impl Hashable for BlockHeader {
671
668
672
669
impl MemoizedHashable for Block {
673
670
fn hashable_bytes ( & self ) -> Vec < u8 > {
674
- self . block_header . to_pb_bytes ( ) . unwrap ( )
671
+ self . block_header
672
+ . to_versioned_pb_bytes ( get_protocol_version ( ) )
673
+ . unwrap ( )
675
674
}
676
675
677
676
fn memoized_hash ( & self ) -> & MemoHash {
@@ -4572,19 +4571,17 @@ mod tests {
4572
4571
let block = block_example ( ) ;
4573
4572
let expected = "70e15ac70bb00f49c7a593b2423f722dca187bbae53dc2f22647063b17608c01" ;
4574
4573
assert_eq ! (
4575
- block. versioned_hash( ProtocolVersion :: Legacy ) . to_string( ) ,
4574
+ block. versioned_hash( ProtocolVersion :: V1_6 ) . to_string( ) ,
4576
4575
expected
4577
4576
) ;
4578
4577
let expected = "29ef68357a5c861b9dbe043d351a28472ca450edcda25de4c9b80a4560a28c0f" ;
4579
4578
assert_eq ! (
4580
- block
4581
- . versioned_hash( ProtocolVersion :: Transition )
4582
- . to_string( ) ,
4579
+ block. versioned_hash( ProtocolVersion :: V1_7 ) . to_string( ) ,
4583
4580
expected
4584
4581
) ;
4585
4582
let expected = "29ef68357a5c861b9dbe043d351a28472ca450edcda25de4c9b80a4560a28c0f" ;
4586
4583
assert_eq ! (
4587
- block. versioned_hash( ProtocolVersion :: Final ) . to_string( ) ,
4584
+ block. versioned_hash( ProtocolVersion :: V2_0 ) . to_string( ) ,
4588
4585
expected
4589
4586
) ;
4590
4587
}
@@ -6658,7 +6655,6 @@ mod tests {
6658
6655
1 ,
6659
6656
Hash :: default ( ) ,
6660
6657
1 ,
6661
- ProtocolVersion :: Legacy ,
6662
6658
) ;
6663
6659
6664
6660
let expected_indices = vec ! [ 0 , 2 , 2 ] ;
@@ -6713,7 +6709,6 @@ mod tests {
6713
6709
1 ,
6714
6710
Hash :: default ( ) ,
6715
6711
1 ,
6716
- ProtocolVersion :: Legacy ,
6717
6712
) ;
6718
6713
6719
6714
let expected_indices = vec ! [ 0 , 2 , 2 , 8 , 10 , 6 , 4 , 6 ] ;
@@ -6749,7 +6744,6 @@ mod tests {
6749
6744
1 ,
6750
6745
Hash :: default ( ) ,
6751
6746
1 ,
6752
- ProtocolVersion :: Legacy ,
6753
6747
) ;
6754
6748
6755
6749
let result = sb. dr_proof_of_inclusion ( & [ b1, b2] , & dr_txs[ 2 ] ) ;
@@ -6760,14 +6754,7 @@ mod tests {
6760
6754
fn test_dr_merkle_root_no_block ( ) {
6761
6755
let dr_txs = build_test_dr_txs ( 3 ) ;
6762
6756
6763
- let sb = mining_build_superblock (
6764
- & [ ] ,
6765
- & [ Hash :: default ( ) ] ,
6766
- 1 ,
6767
- Hash :: default ( ) ,
6768
- 1 ,
6769
- ProtocolVersion :: Legacy ,
6770
- ) ;
6757
+ let sb = mining_build_superblock ( & [ ] , & [ Hash :: default ( ) ] , 1 , Hash :: default ( ) , 1 ) ;
6771
6758
6772
6759
let result = sb. dr_proof_of_inclusion ( & [ ] , & dr_txs[ 2 ] ) ;
6773
6760
assert ! ( result. is_none( ) ) ;
@@ -6793,7 +6780,6 @@ mod tests {
6793
6780
1 ,
6794
6781
Hash :: default ( ) ,
6795
6782
1 ,
6796
- ProtocolVersion :: Legacy ,
6797
6783
) ;
6798
6784
6799
6785
let expected_indices = vec ! [ 0 , 2 ] ;
@@ -6832,7 +6818,6 @@ mod tests {
6832
6818
1 ,
6833
6819
Hash :: default ( ) ,
6834
6820
1 ,
6835
- ProtocolVersion :: Legacy ,
6836
6821
) ;
6837
6822
6838
6823
let expected_indices = vec ! [ 0 , 2 , 2 ] ;
@@ -6895,7 +6880,6 @@ mod tests {
6895
6880
1 ,
6896
6881
Hash :: default ( ) ,
6897
6882
1 ,
6898
- ProtocolVersion :: Legacy ,
6899
6883
) ;
6900
6884
6901
6885
let expected_indices = vec ! [ 0 , 2 , 2 , 8 , 10 , 6 , 4 , 6 ] ;
@@ -6931,7 +6915,6 @@ mod tests {
6931
6915
1 ,
6932
6916
Hash :: default ( ) ,
6933
6917
1 ,
6934
- ProtocolVersion :: Legacy ,
6935
6918
) ;
6936
6919
6937
6920
let result = sb. tally_proof_of_inclusion ( & [ b1, b2] , & tally_txs[ 2 ] ) ;
@@ -6963,7 +6946,6 @@ mod tests {
6963
6946
1 ,
6964
6947
Hash :: default ( ) ,
6965
6948
1 ,
6966
- ProtocolVersion :: Legacy ,
6967
6949
) ;
6968
6950
6969
6951
let expected_indices = vec ! [ 0 , 2 , 2 ] ;
0 commit comments