-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(consensus): stub out tower module, tower_sync vote ixs
This PR stubs out the fd_tower module which will implement various safe guards in the consensus protocol (threshold check, switch proof). It also stubs out the new tower_sync instruction in the vote program. Implementation in PR to follow.
- Loading branch information
Showing
17 changed files
with
301 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "fd_tower.h" | ||
|
||
int | ||
fd_tower_threshold_check( fd_tower_t * tower, | ||
ulong total_stake, | ||
ulong threshold_depth, | ||
float threshold_pct ) { | ||
if( FD_UNLIKELY( tower->slots_cnt < threshold_depth ) ) return 1; | ||
ulong slot = tower->slots[tower->slots_cnt - threshold_depth]; | ||
fd_hash_t const * hash = fd_blockstore_bank_hash_query( tower->blockstore, slot ); | ||
fd_slot_hash_t slot_hash = { .slot = slot, .hash = *hash }; | ||
|
||
fd_ghost_node_t const * ghost_node = fd_ghost_node_query( tower->ghost, &slot_hash ); | ||
|
||
#if FD_TOWER_USE_HANDHOLDING | ||
|
||
/* This shouldn't happen because slot hashes are inserted into the ghost upon execution. Indicates | ||
* a likely programming error. */ | ||
|
||
if( FD_UNLIKELY( ghost_node == NULL ) ) { | ||
FD_LOG_ERR( ( "invariant violation: slot %lu, hash: %32J not found in ghost", slot, hash->hash ) ); | ||
} | ||
|
||
#endif | ||
|
||
float pct = (float)ghost_node->weight / (float)total_stake; | ||
return pct > threshold_pct; | ||
} | ||
|
||
int | ||
fd_tower_switch_proof_construct( fd_tower_t * tower ) { | ||
FD_LOG_ERR(("unimplemented")); | ||
} |
Oops, something went wrong.