@@ -191,15 +191,15 @@ insert_vote_state_into_funk_txn( fd_funk_t * funk,
191
191
FD_TEST ( fd_vote_state_versioned_encode ( vote_state_versioned , & encode_ctx )== 0 );
192
192
}
193
193
194
- void
194
+ ulong
195
195
voter_vote_for_slot ( fd_wksp_t * wksp ,
196
196
fd_tower_t * tower ,
197
197
fd_funk_t * funk ,
198
198
ulong vote_slot ,
199
199
ulong slot ,
200
200
voter_t * voter ) {
201
201
// Update tower with vote
202
- fd_tower_vote ( tower , vote_slot );
202
+ ulong root = fd_tower_vote ( tower , vote_slot );
203
203
204
204
// Convert updated tower to vote state
205
205
fd_vote_state_versioned_t * vote_state_versioned = tower_to_vote_state ( wksp , tower , voter );
@@ -209,6 +209,8 @@ voter_vote_for_slot( fd_wksp_t * wksp,
209
209
210
210
// Insert updated vote state into funk
211
211
insert_vote_state_into_funk_txn ( funk , funk_txn , & voter -> pubkey , vote_state_versioned );
212
+
213
+ return root ;
212
214
}
213
215
214
216
fd_epoch_t *
@@ -318,7 +320,7 @@ test_vote_simple( fd_wksp_t * wksp ) {
318
320
init_vote_accounts ( voters , voter_cnt );
319
321
320
322
ulong stakes [] = {10000 , 10000 , 10000 , 10000 , 10000 };
321
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
323
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
322
324
323
325
/**********************************************************************/
324
326
/* Setup funk_txns for each slot with vote account funk records */
@@ -413,7 +415,7 @@ test_vote_switch_check( fd_wksp_t * wksp ) {
413
415
init_vote_accounts ( voters , voter_cnt );
414
416
415
417
ulong stakes [] = {10000 , 10000 , 10000 , 10000 , 10000 };
416
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
418
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
417
419
418
420
/**********************************************************************/
419
421
/* Setup funk_txns for each slot with vote account funk records */
@@ -535,7 +537,7 @@ test_vote_switch_check_4forks( fd_wksp_t * wksp ) {
535
537
init_vote_accounts ( voters , voter_cnt );
536
538
537
539
ulong stakes [] = {10000 , 10000 , 10000 , 20001 };
538
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
540
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
539
541
540
542
/**********************************************************************/
541
543
/* Setup funk_txns for each slot with vote account funk records */
@@ -651,7 +653,7 @@ test_vote_lockout_check( fd_wksp_t * wksp ) {
651
653
init_vote_accounts ( voters , voter_cnt );
652
654
653
655
ulong stakes [] = {10000 , 10000 , 10000 , 10000 , 10000 };
654
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
656
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
655
657
656
658
/**********************************************************************/
657
659
/* Setup funk_txns for each slot with vote account funk records */
@@ -772,7 +774,7 @@ test_vote_threshold_check( fd_wksp_t * wksp ) {
772
774
init_vote_accounts ( voters , voter_cnt );
773
775
774
776
ulong stakes [] = {10000 , 10000 , 10000 , 10000 , 10000 };
775
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
777
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
776
778
777
779
/**********************************************************************/
778
780
/* Initialize a funk_txn for each slot with vote account funk records */
@@ -908,7 +910,8 @@ test_full_tower( fd_wksp_t * wksp ) {
908
910
void * ghost_mem = fd_wksp_alloc_laddr ( wksp , fd_ghost_align (), fd_ghost_footprint ( FD_BLOCK_MAX ), 1UL );
909
911
fd_ghost_t * ghost = fd_ghost_join ( fd_ghost_new ( ghost_mem , 0UL , FD_BLOCK_MAX ) );
910
912
911
- ghost_init ( ghost , 331233273 , funk );
913
+ ghost_init ( ghost , 331233272 , funk );
914
+ ghost_insert ( ghost , 331233272 , 331233273 , funk );
912
915
ghost_insert ( ghost , 331233273 , 331233274 , funk );
913
916
ghost_insert ( ghost , 331233274 , 331233275 , funk );
914
917
ghost_insert ( ghost , 331233275 , 331233276 , funk );
@@ -972,103 +975,68 @@ test_full_tower( fd_wksp_t * wksp ) {
972
975
init_vote_accounts ( voters , voter_cnt );
973
976
974
977
ulong stakes [] = {12 , 27 , 16 , 7 , 38 };
975
- fd_epoch_t * epoch = mock_epoch (wksp , voter_cnt , stakes , voters );
978
+ fd_epoch_t * epoch = mock_epoch ( wksp , voter_cnt , stakes , voters );
976
979
977
- fd_ghost_print ( ghost , epoch , fd_ghost_root (ghost ) );
978
980
/**********************************************************************/
979
981
/* Setup funk_txns for each slot with vote account funk records */
980
982
/**********************************************************************/
981
983
void * tower_mems [voter_cnt ];
984
+ fd_tower_t * towers [voter_cnt ];
982
985
for (ulong i = 0 ; i < voter_cnt ; i ++ ) {
983
986
tower_mems [i ] = fd_wksp_alloc_laddr ( wksp , fd_tower_align (), fd_tower_footprint (), 6UL );
987
+ towers [i ] = TOWER ( tower_mems [i ], 331233272 , 331233273 , 331233274 ,
988
+ 331233275 , 331233276 , 331233277 , 331233278 ,
989
+ 331233279 , 331233280 , 331233281 , 331233282 ,
990
+ 331233283 , 331233284 , 331233285 , 331233286 ,
991
+ 331233287 , 331233288 , 331233289 , 331233290 ,
992
+ 331233291 , 331233292 , 331233293 , 331233294 ,
993
+ 331233295 , 331233296 , 331233297 , 331233298 ,
994
+ 331233299 , 331233300 , 331233301 , 331233302 );
984
995
}
985
- fd_tower_t * towers [] = {
986
- TOWER ( tower_mems [0 ], 331233273 , 331233274 , 331233275 , 331233276 ,
987
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
988
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
989
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
990
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
991
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
992
- 331233302 , 331233303 ),
993
- TOWER ( tower_mems [1 ], 331233273 , 331233274 , 331233275 , 331233276 ,
994
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
995
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
996
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
997
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
998
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
999
- 331233302 , 331233303 ),
1000
- TOWER ( tower_mems [2 ], 331233273 , 331233274 , 331233275 , 331233276 ,
1001
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
1002
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
1003
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
1004
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
1005
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
1006
- 331233302 , 331233303 ),
1007
- TOWER ( tower_mems [3 ], 331233273 , 331233274 , 331233275 , 331233276 ,
1008
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
1009
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
1010
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
1011
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
1012
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
1013
- 331233302 , 331233303 ),
1014
- TOWER ( tower_mems [4 ], 331233273 , 331233274 , 331233275 , 331233276 ,
1015
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
1016
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
1017
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
1018
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
1019
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
1020
- 331233302 , 331233303 )
1021
- };
1022
996
1023
997
/**********************************************************************/
1024
998
/* Initialize landed votes per validator in funk */
1025
999
/**********************************************************************/
1026
- voter_vote_for_slot ( wksp , towers [0 ], funk , 331233302 , 331233303 , & voters [0 ] );
1027
- voter_vote_for_slot ( wksp , towers [1 ], funk , 331233302 , 331233303 , & voters [1 ] );
1028
- voter_vote_for_slot ( wksp , towers [2 ], funk , 331233302 , 331233303 , & voters [2 ] );
1029
- voter_vote_for_slot ( wksp , towers [3 ], funk , 331233302 , 331233303 , & voters [3 ] );
1030
- voter_vote_for_slot ( wksp , towers [4 ], funk , 331233302 , 331233303 , & voters [4 ] );
1000
+
1001
+ voter_vote_for_slot ( wksp , towers [0 ], funk , 331233303 , 331233304 , & voters [0 ] );
1002
+ voter_vote_for_slot ( wksp , towers [1 ], funk , 331233303 , 331233304 , & voters [1 ] );
1003
+ voter_vote_for_slot ( wksp , towers [2 ], funk , 331233303 , 331233304 , & voters [2 ] );
1004
+ voter_vote_for_slot ( wksp , towers [3 ], funk , 331233303 , 331233304 , & voters [3 ] );
1005
+ voter_vote_for_slot ( wksp , towers [4 ], funk , 331233303 , 331233304 , & voters [4 ] );
1031
1006
1032
1007
/**********************************************************************/
1033
1008
/* Initialize tower, spad and setup forks */
1034
1009
/**********************************************************************/
1035
1010
void * tower_mem = fd_wksp_alloc_laddr ( wksp , fd_tower_align (), fd_tower_footprint (), 6UL );
1036
- fd_tower_t * tower = TOWER ( tower_mem , 331233273 , 331233274 , 331233275 , 331233276 ,
1037
- 331233277 , 331233278 , 331233279 , 331233280 , 331233281 ,
1038
- 331233282 , 331233283 , 331233284 , 331233285 , 331233286 ,
1039
- 331233287 , 331233288 , 331233289 , 331233290 , 331233291 ,
1040
- 331233292 , 331233293 , 331233294 , 331233295 , 331233296 ,
1041
- 331233297 , 331233298 , 331233299 , 331233300 , 331233301 ,
1042
- 331233302 , 331233303 );
1011
+ fd_tower_t * tower = TOWER ( tower_mem , 331233272 , 331233273 , 331233274 ,
1012
+ 331233275 , 331233276 , 331233277 , 331233278 ,
1013
+ 331233279 , 331233280 , 331233281 , 331233282 ,
1014
+ 331233283 , 331233284 , 331233285 , 331233286 ,
1015
+ 331233287 , 331233288 , 331233289 , 331233290 ,
1016
+ 331233291 , 331233292 , 331233293 , 331233294 ,
1017
+ 331233295 , 331233296 , 331233297 , 331233298 ,
1018
+ 331233299 , 331233300 , 331233301 , 331233302 );
1043
1019
FD_TEST ( tower );
1044
1020
1045
1021
void * spad_mem = fd_wksp_alloc_laddr ( wksp , fd_spad_align (), fd_spad_footprint ( FD_TOWER_FOOTPRINT ), 5UL );
1046
1022
fd_spad_t * spad = fd_spad_join ( fd_spad_new ( spad_mem , FD_TOWER_FOOTPRINT ) );
1047
1023
1048
1024
fd_forks_t * forks ;
1049
- ulong frontier1 = 331233303UL ;
1025
+ ulong frontier1 = 331233304UL ;
1026
+ ulong frontier2 = 331233308UL ;
1050
1027
INIT_FORKS ( frontier1 );
1051
- fd_forks_update ( forks , epoch , funk , ghost , frontier1 );
1052
-
1053
-
1054
- fd_funk_txn_xid_t xid ;
1055
- xid .ul [0 ] = xid .ul [1 ] = 331233304 ;
1056
- fd_funk_txn_map_query_t query [1 ];
1057
- fd_funk_txn_map_t txn_map = fd_funk_txn_map ( funk , fd_funk_wksp ( funk ) );
1058
- fd_funk_txn_map_query_try ( & txn_map , & xid , NULL , query , 0 );
1059
- FD_TEST ( query -> ele );
1028
+ ADD_FRONTIER_TO_FORKS ( frontier2 );
1060
1029
1061
- fd_tower_vote ( towers [1 ], 331233304 );
1062
- // fd_landed_vote_t * landed_votes = mock_landed_votes( wksp, 331233304, towers[1], 30 );
1063
- // set_vote_account_tower( wksp, funk, query->ele, &voter[1], landed_votes );
1064
- // VOTE_FOR_SLOT( 331233303UL, 331233304, 0 );
1030
+ fd_forks_update ( forks , epoch , funk , ghost , frontier1 );
1031
+ fd_ghost_print ( ghost , epoch , fd_ghost_root (ghost ) );
1065
1032
1033
+ voter_vote_for_slot ( wksp , towers [1 ], funk , 331233304 , 331233304 , & voters [1 ] );
1066
1034
1035
+ fd_forks_update ( forks , epoch , funk , ghost , frontier1 );
1036
+ fd_ghost_print ( ghost , epoch , fd_ghost_root (ghost ) );
1067
1037
1068
1038
/* Everyone has voted for slot 331233302 in their towers by slot 331233303 */
1069
1039
// fd_tower_t * tower = mock_tower( wksp, 31, votes );
1070
- FD_LOG_NOTICE (( "Updated ghost:" ));
1071
- fd_ghost_print ( ghost , epoch , fd_ghost_root (ghost ) );
1072
1040
1073
1041
// ulong root = fd_tower_vote( tower, 331233303 );
1074
1042
// fd_tower_vote( tower, 331233303 );
@@ -1102,7 +1070,7 @@ main( int argc, char ** argv ) {
1102
1070
test_vote_lockout_check ( wksp );
1103
1071
test_vote_threshold_check ( wksp );
1104
1072
test_vote_switch_check_4forks ( wksp );
1105
- // test_full_tower( wksp );
1073
+ test_full_tower ( wksp );
1106
1074
fd_halt ();
1107
1075
return 0 ;
1108
1076
}
0 commit comments