-
Notifications
You must be signed in to change notification settings - Fork 242
repair: fix forest to handle forks from non-frontier slots #4873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emwang-jump
wants to merge
1
commit into
main
Choose a base branch
from
emwang/forest-fork-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+87
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -284,6 +284,33 @@ advance_frontier( fd_forest_t * forest, ulong slot, ushort parent_off ) { | |
ulong parent_slot = slot - parent_off; | ||
ele = fd_ptr_if( !ele, fd_forest_frontier_ele_query( fd_forest_frontier( forest ), &parent_slot, NULL, pool ), ele ); | ||
|
||
/* There's an edge case where a fork begins from from somewhere behind | ||
the frontier */ | ||
if( FD_UNLIKELY( !ele ) ) { | ||
// traverse up the tree to see if we can find a parent | ||
ele = fd_forest_ancestry_ele_query( ancestry, &slot, NULL, pool ); | ||
ulong parent_idx = ele->parent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ancestor |
||
int found_parent_on_frontier = 0; | ||
while( parent_idx != null ) { | ||
fd_forest_ele_t * parent = fd_forest_pool_ele( pool, parent_idx ); | ||
if( fd_forest_frontier_ele_query( fd_forest_frontier( forest ), &parent->slot, NULL, pool ) ){ | ||
found_parent_on_frontier = 1; | ||
break; | ||
} | ||
parent_idx = parent->parent; | ||
} | ||
|
||
if( FD_UNLIKELY( !found_parent_on_frontier ) ) { | ||
ele = fd_forest_ancestry_ele_remove( ancestry, &slot, NULL, pool ); | ||
fd_forest_frontier_ele_insert( fd_forest_frontier( forest ), ele, pool ); | ||
} else { | ||
/* We hit this case when we are not on frontier, parent is not on | ||
frontier, but grandparent is on frontier. Which means this data | ||
shred will not be advancing the frontier. */ | ||
Comment on lines
+307
to
+309
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ancestor |
||
return; | ||
} | ||
} | ||
|
||
fd_forest_ele_t * head = ele; | ||
fd_forest_ele_t * tail = head; | ||
fd_forest_ele_t * prev = NULL; | ||
|
@@ -310,10 +337,10 @@ advance_frontier( fd_forest_t * forest, ulong slot, ushort parent_off ) { | |
|
||
static fd_forest_ele_t * | ||
query( fd_forest_t * forest, ulong slot ) { | ||
fd_forest_ele_t * pool = fd_forest_pool( forest ); | ||
fd_forest_ancestry_t * ancestry = fd_forest_ancestry( forest ); | ||
fd_forest_frontier_t * frontier = fd_forest_frontier( forest ); | ||
fd_forest_orphaned_t * orphaned = fd_forest_orphaned( forest ); | ||
fd_forest_ele_t * pool = fd_forest_pool( forest ); | ||
fd_forest_ancestry_t * ancestry = fd_forest_ancestry( forest ); | ||
fd_forest_frontier_t * frontier = fd_forest_frontier( forest ); | ||
fd_forest_orphaned_t * orphaned = fd_forest_orphaned( forest ); | ||
|
||
fd_forest_ele_t * ele; | ||
ele = fd_forest_ancestry_ele_query( ancestry, &slot, NULL, pool ); | ||
|
@@ -424,7 +451,7 @@ fd_forest_publish( fd_forest_t * forest, ulong new_root_slot ) { | |
head points to the queue head (initialized with old_root_ele). */ | ||
|
||
fd_forest_ele_t * head = ancestry_frontier_remove( forest, old_root_ele->slot ); | ||
head->next = null; | ||
head->next = null; | ||
fd_forest_ele_t * tail = head; | ||
|
||
/* Second, BFS down the tree, inserting each ele into the prune queue | ||
|
@@ -607,11 +634,6 @@ fd_forest_ancestry_print( fd_forest_t const * forest ) { | |
FD_LOG_NOTICE( ( "\n\n[Ancestry]\n%lu", fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root )->slot ) ); | ||
|
||
ancestry_print2( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root ), NULL, 0, 0, "" ); | ||
|
||
//FD_LOG_NOTICE(("\n\n[Ancestry]\n%lu", fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root )->slot ) ); | ||
|
||
//ancestry_print( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root ), 0, "" ); | ||
|
||
} | ||
|
||
void | ||
|
@@ -623,7 +645,8 @@ fd_forest_frontier_print( fd_forest_t const * forest ) { | |
!fd_forest_frontier_iter_done( iter, frontier, pool ); | ||
iter = fd_forest_frontier_iter_next( iter, frontier, pool ) ) { | ||
fd_forest_ele_t const * ele = fd_forest_frontier_iter_ele_const( iter, frontier, pool ); | ||
ancestry_print2( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), fd_forest_pool_idx( pool, ele ) ), NULL, 0, 0, "" ); | ||
printf( "%lu (%u/%u)\n", ele->slot, ele->buffered_idx + 1, ele->complete_idx + 1 ); | ||
//ancestry_print2( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), fd_forest_pool_idx( pool, ele ) ), NULL, 0, 0, "" ); | ||
|
||
} | ||
} | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... should this logic live in the
insert
helper function in forest instead?