1
- use crate :: {
2
- chain:: { ChainInfo , Environment , Epoch , PublicKeyHash } ,
3
- register_protocol_version, ProtocolVersion ,
4
- } ;
1
+ use crate :: chain:: { Environment , Epoch , PublicKeyHash } ;
5
2
use serde:: { Deserialize , Serialize } ;
6
3
use std:: collections:: { HashMap , HashSet } ;
7
4
8
- const ONE_HOUR : u32 = 80 ;
9
- const TWO_WEEKS : u32 = 26_880 ;
5
+ // const ONE_HOUR: u32 = 80;
6
+ // const TWO_WEEKS: u32 = 26_880;
10
7
11
8
/// Committee for superblock indices 750-1344
12
9
const FIRST_EMERGENCY_COMMITTEE : [ & str ; 7 ] = [
@@ -89,8 +86,7 @@ pub fn wip_info() -> HashMap<String, Epoch> {
89
86
active_wips. insert ( "WIP0025" . to_string ( ) , 1708901 ) ;
90
87
active_wips. insert ( "WIP0026" . to_string ( ) , 1708901 ) ;
91
88
active_wips. insert ( "WIP0027" . to_string ( ) , 1708901 ) ;
92
- // TODO: Add epoch when WIP0028 was activated
93
- // active_wips.insert("WIP0028".to_string(), 2949141);
89
+ active_wips. insert ( "WIP0028" . to_string ( ) , 3048961 ) ;
94
90
95
91
active_wips
96
92
}
@@ -110,7 +106,7 @@ fn test_wip_info() -> HashMap<String, Epoch> {
110
106
active_wips. insert ( "WIP0025" . to_string ( ) , 0 ) ;
111
107
active_wips. insert ( "WIP0026" . to_string ( ) , 0 ) ;
112
108
active_wips. insert ( "WIP0027" . to_string ( ) , 0 ) ;
113
- // active_wips.insert("WIP0028".to_string(), 0);
109
+ active_wips. insert ( "WIP0028" . to_string ( ) , 0 ) ;
114
110
115
111
active_wips
116
112
}
@@ -140,8 +136,6 @@ impl TapiEngine {
140
136
epoch_to_update : Epoch ,
141
137
block_epoch : Epoch ,
142
138
avoid_wip_list : & HashSet < String > ,
143
- checkpoints_period : u16 ,
144
- chain_info : & mut ChainInfo ,
145
139
) {
146
140
// In case of empty epochs, they would be considered as blocks with tapi version to 0
147
141
// In order to not update bit counter from old blocks where the block version was not used,
@@ -152,14 +146,7 @@ impl TapiEngine {
152
146
let init = self . bit_tapi_counter . last_epoch + 1 ;
153
147
let end = epoch_to_update;
154
148
for i in init..end {
155
- self . update_bit_counter (
156
- 0 ,
157
- i,
158
- block_epoch,
159
- avoid_wip_list,
160
- checkpoints_period,
161
- chain_info,
162
- ) ;
149
+ self . update_bit_counter ( 0 , i, block_epoch, avoid_wip_list) ;
163
150
}
164
151
}
165
152
for n in 0 ..self . bit_tapi_counter . len ( ) {
@@ -184,21 +171,6 @@ impl TapiEngine {
184
171
let scheduled_epoch = block_epoch + 21 ;
185
172
self . wip_activation
186
173
. insert ( bit_counter. wip . clone ( ) , scheduled_epoch) ;
187
- if bit_counter. wip == "WIP0028" {
188
- log:: info!( "WIP0028 has passed. Protocol V1_8 will be scheduled for epoch {}" , scheduled_epoch) ;
189
- register_protocol_version (
190
- ProtocolVersion :: V1_8 ,
191
- scheduled_epoch,
192
- checkpoints_period,
193
- ) ;
194
- // Register the 1_8 protocol into chain state (namely, chain info) so that
195
- // the scheduled activation data eventually gets persisted into storage.
196
- chain_info. protocol . register (
197
- scheduled_epoch,
198
- ProtocolVersion :: V1_8 ,
199
- checkpoints_period,
200
- ) ;
201
- }
202
174
}
203
175
bit_counter. votes = 0 ;
204
176
}
@@ -212,44 +184,21 @@ impl TapiEngine {
212
184
& mut self ,
213
185
environment : Environment ,
214
186
) -> ( Epoch , HashSet < String > ) {
215
- let mut voting_wips = vec ! [ None ; 32 ] ;
187
+ let voting_wips = vec ! [ None ; 32 ] ;
216
188
217
189
match environment {
218
190
Environment :: Mainnet => {
219
191
// Hardcoded information about WIPs
220
192
for ( k, v) in wip_info ( ) {
221
193
self . wip_activation . insert ( k, v) ;
222
194
}
223
-
224
- // Hardcoded information about WIPs in vote processing
225
- let wip_0028 = BitVotesCounter {
226
- votes : 0 ,
227
- period : TWO_WEEKS ,
228
- wip : "WIP0028" . to_string ( ) ,
229
- // Start signaling on December 14 at 9am UTC
230
- init : 2922240 ,
231
- end : u32:: MAX ,
232
- bit : 9 ,
233
- } ;
234
- voting_wips[ 9 ] = Some ( wip_0028) ;
235
195
}
236
196
Environment :: Testnet | Environment :: Development => {
237
197
// In non-mainnet chains, all the WIPs that are active in mainnet are considered
238
198
// active since epoch 0.
239
199
for ( k, v) in test_wip_info ( ) {
240
200
self . wip_activation . insert ( k, v) ;
241
201
}
242
-
243
- // Hardcoded information about WIPs in vote processing
244
- let wip_0028 = BitVotesCounter {
245
- votes : 0 ,
246
- period : ONE_HOUR ,
247
- wip : "WIP0028" . to_string ( ) ,
248
- init : 0 ,
249
- end : u32:: MAX ,
250
- bit : 9 ,
251
- } ;
252
- voting_wips[ 9 ] = Some ( wip_0028) ;
253
202
}
254
203
} ;
255
204
@@ -457,7 +406,7 @@ pub fn in_emergency_period(
457
406
)
458
407
} else if Environment :: Mainnet == environment
459
408
&& superblock_index > 224_300
460
- && superblock_index < 292_224
409
+ && superblock_index < 304_896
461
410
{
462
411
Some (
463
412
FOURTH_EMERGENCY_COMMITTEE
@@ -705,7 +654,6 @@ mod tests {
705
654
#[ test]
706
655
fn test_update_bit_counter ( ) {
707
656
let empty_hs = HashSet :: default ( ) ;
708
- let mut chain_info = ChainInfo :: default ( ) ;
709
657
let mut t = TapiEngine :: default ( ) ;
710
658
let bit = 0 ;
711
659
let wip = BitVotesCounter {
@@ -719,42 +667,42 @@ mod tests {
719
667
t. bit_tapi_counter . insert ( wip) ;
720
668
assert_eq ! ( t. bit_tapi_counter. last_epoch, 0 ) ;
721
669
722
- t. update_bit_counter ( 1 , 9_999 , 9_999 , & empty_hs, 45 , & mut chain_info ) ;
670
+ t. update_bit_counter ( 1 , 9_999 , 9_999 , & empty_hs) ;
723
671
// Updating with epoch < init does not increase the votes counter
724
672
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 0 ) ;
725
673
assert_eq ! ( t. bit_tapi_counter. last_epoch, 9_999 ) ;
726
674
727
- t. update_bit_counter ( 1 , 10_000 , 10_000 , & empty_hs, 45 , & mut chain_info ) ;
675
+ t. update_bit_counter ( 1 , 10_000 , 10_000 , & empty_hs) ;
728
676
// Updating with epoch >= init does increase the votes counter
729
677
// But since this is the first epoch, the votes counter is reset to 0 again afterwards
730
678
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 0 ) ;
731
679
732
- t. update_bit_counter ( 1 , 10_001 , 10_001 , & empty_hs, 45 , & mut chain_info ) ;
680
+ t. update_bit_counter ( 1 , 10_001 , 10_001 , & empty_hs) ;
733
681
// Updating with epoch >= init does increase the votes counter
734
682
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 1 ) ;
735
683
736
- t. update_bit_counter ( 1 , 10_002 , 10_002 , & empty_hs, 45 , & mut chain_info ) ;
684
+ t. update_bit_counter ( 1 , 10_002 , 10_002 , & empty_hs) ;
737
685
// Updating with epoch >= init does increase the votes counter
738
686
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 2 ) ;
739
687
740
688
// Updating with an epoch that was already updated will count the votes twice, there is no
741
689
// protection against this because the update_new_wip_votes function must be able to count
742
690
// votes from old blocks
743
691
/*
744
- t.update_bit_counter(1, 10_002, &empty_hs, 45, &mut chain_info );
692
+ t.update_bit_counter(1, 10_002, &empty_hs);
745
693
*/
746
694
747
- t. update_bit_counter ( 0 , 10_003 , 10_003 , & empty_hs, 45 , & mut chain_info ) ;
695
+ t. update_bit_counter ( 0 , 10_003 , 10_003 , & empty_hs) ;
748
696
// Updating with epoch >= init but voting against does not increase the votes counter
749
697
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 2 ) ;
750
698
751
- t. update_bit_counter ( 0 , 10_103 , 10_103 , & empty_hs, 45 , & mut chain_info ) ;
699
+ t. update_bit_counter ( 0 , 10_103 , 10_103 , & empty_hs) ;
752
700
// The vote counting is at epoch 10_100, the votes should be reset to 0
753
701
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 0 ) ;
754
702
755
703
// Add 90 votes to test activation
756
704
for epoch in 10_200 ..10_290 {
757
- t. update_bit_counter ( 1 , epoch, epoch, & empty_hs, 45 , & mut chain_info ) ;
705
+ t. update_bit_counter ( 1 , epoch, epoch, & empty_hs) ;
758
706
}
759
707
// More than 80% of votes means that the WIP should activate at the next counting epoch
760
708
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 89 ) ;
@@ -765,7 +713,7 @@ mod tests {
765
713
// so that all the blocks after 10_321 are validated using the new validation logic, or
766
714
// change the WIP activation date to 10_501?
767
715
// Decided to change the WIP activation date to 10_521
768
- t. update_bit_counter ( 0 , 10_500 , 10_500 , & empty_hs, 45 , & mut chain_info ) ;
716
+ t. update_bit_counter ( 0 , 10_500 , 10_500 , & empty_hs) ;
769
717
// The votes counter should reset
770
718
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 0 ) ;
771
719
// The activation date should be
@@ -775,7 +723,6 @@ mod tests {
775
723
#[ test]
776
724
fn test_update_bit_counter_multi_vote ( ) {
777
725
let empty_hs = HashSet :: default ( ) ;
778
- let mut chain_info = ChainInfo :: default ( ) ;
779
726
let mut t = TapiEngine :: default ( ) ;
780
727
let wip0 = BitVotesCounter {
781
728
votes : 0 ,
@@ -798,35 +745,35 @@ mod tests {
798
745
assert_eq ! ( t. bit_tapi_counter. last_epoch, 0 ) ;
799
746
800
747
// Vote for none
801
- t. update_bit_counter ( 0 , 10_001 , 10_001 , & empty_hs, 45 , & mut chain_info ) ;
748
+ t. update_bit_counter ( 0 , 10_001 , 10_001 , & empty_hs) ;
802
749
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 0 ) ;
803
750
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 0 ) ;
804
751
assert_eq ! ( t. bit_tapi_counter. last_epoch, 10_001 ) ;
805
752
806
753
// Vote for both
807
- t. update_bit_counter ( 3 , 10_002 , 10_002 , & empty_hs, 45 , & mut chain_info ) ;
754
+ t. update_bit_counter ( 3 , 10_002 , 10_002 , & empty_hs) ;
808
755
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 1 ) ;
809
756
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 1 ) ;
810
757
811
758
// Vote only for wip0
812
- t. update_bit_counter ( 1 , 10_002 , 10_002 , & empty_hs, 45 , & mut chain_info ) ;
759
+ t. update_bit_counter ( 1 , 10_002 , 10_002 , & empty_hs) ;
813
760
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 2 ) ;
814
761
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 1 ) ;
815
762
816
763
// Vote only for wip1
817
- t. update_bit_counter ( 2 , 10_002 , 10_002 , & empty_hs, 45 , & mut chain_info ) ;
764
+ t. update_bit_counter ( 2 , 10_002 , 10_002 , & empty_hs) ;
818
765
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 2 ) ;
819
766
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 2 ) ;
820
767
821
768
// Add 90 votes to test activation of both wips in the same epoch
822
769
for epoch in 10_003 ..10_093 {
823
- t. update_bit_counter ( 3 , epoch, epoch, & empty_hs, 45 , & mut chain_info ) ;
770
+ t. update_bit_counter ( 3 , epoch, epoch, & empty_hs) ;
824
771
}
825
772
826
773
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 92 ) ;
827
774
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 92 ) ;
828
775
829
- t. update_bit_counter ( 0 , 10_100 , 10_100 , & empty_hs, 45 , & mut chain_info ) ;
776
+ t. update_bit_counter ( 0 , 10_100 , 10_100 , & empty_hs) ;
830
777
// The votes counter should reset
831
778
assert_eq ! ( t. bit_tapi_counter. info[ 0 ] . clone( ) . unwrap( ) . votes, 0 ) ;
832
779
assert_eq ! ( t. bit_tapi_counter. info[ 1 ] . clone( ) . unwrap( ) . votes, 0 ) ;
@@ -840,7 +787,6 @@ mod tests {
840
787
// Check that voting for unallocated wips is allowed, but the extra votes are not counted,
841
788
// and the votes for active bits are valid
842
789
let empty_hs = HashSet :: default ( ) ;
843
- let mut chain_info = ChainInfo :: default ( ) ;
844
790
let mut t = TapiEngine :: default ( ) ;
845
791
let bit = 0 ;
846
792
let wip = BitVotesCounter {
@@ -855,7 +801,7 @@ mod tests {
855
801
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 0 ) ;
856
802
857
803
// Vote "yes" to all the 32 bits, even though there is only 1 active wip (bit 0)
858
- t. update_bit_counter ( u32:: MAX , 10_001 , 10_001 , & empty_hs, 45 , & mut chain_info ) ;
804
+ t. update_bit_counter ( u32:: MAX , 10_001 , 10_001 , & empty_hs) ;
859
805
// This is a valid block and a valid vote
860
806
assert_eq ! ( t. bit_tapi_counter. info[ bit] . clone( ) . unwrap( ) . votes, 1 ) ;
861
807
}
@@ -866,8 +812,7 @@ mod tests {
866
812
867
813
let ( epoch, old_wips) = t. initialize_wip_information ( Environment :: Mainnet ) ;
868
814
// The first block whose vote must be counted is the one from WIP0028
869
- let init_epoch_wip0028 = 2922240 ;
870
- assert_eq ! ( epoch, init_epoch_wip0028) ;
815
+ assert_eq ! ( epoch, u32 :: MAX ) ;
871
816
// The TapiEngine was just created, there list of old_wips must be empty
872
817
assert_eq ! ( old_wips, HashSet :: new( ) ) ;
873
818
// The list of active WIPs should match those defined in `wip_info`
@@ -879,9 +824,7 @@ mod tests {
879
824
880
825
// Test initialize_wip_information with a non-empty TapiEngine
881
826
let ( epoch, old_wips) = t. initialize_wip_information ( Environment :: Mainnet ) ;
882
- // WIP0022 is already included and it won't be updated
883
- let mut hs = HashSet :: new ( ) ;
884
- hs. insert ( "WIP0028" . to_string ( ) ) ;
827
+ let hs = HashSet :: new ( ) ;
885
828
assert_eq ! ( old_wips, hs) ;
886
829
887
830
// There is no new WIPs to update so we obtain the max value
0 commit comments