Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

### Fixed

- [#5458](https://github.com/ChainSafe/forest/pull/5458) Fix stack overflow occurring when running Forest in debug mode.

## Forest v0.25.0 "Bombadil"

This is a mandatory release for calibnet node operators. It includes the revised NV25 _Teep_ network upgrade at epoch `2_523_454` which corresponds to `2025-03-26T23:00:00Z`. This release also includes a number of new RPC methods, fixes and other improvements. Be sure to check the breaking changes before upgrading.
Expand Down
42 changes: 22 additions & 20 deletions src/chain_sync/chain_follower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,31 +678,33 @@ impl<DB: Blockstore> SyncStateMachine<DB> {
// Mark all descendants of tipsets as bad.
// Remove all bad tipsets from the tipset map.
fn mark_bad_tipset(&mut self, tipset: Arc<FullTipset>, reason: String) {
self.tipsets.remove(tipset.key());
// Mark all blocks in the tipset as bad
for block in tipset.blocks() {
self.bad_block_cache.put(*block.cid(), reason.clone());
}
let mut stack = vec![tipset];

// Find all descendant tipsets (tipsets that have this tipset as a parent)
let mut to_remove = Vec::new();
let mut descendants = Vec::new();
while let Some(tipset) = stack.pop() {
self.tipsets.remove(tipset.key());
// Mark all blocks in the tipset as bad
for block in tipset.blocks() {
self.bad_block_cache.put(*block.cid(), reason.clone());
}

// Find all descendant tipsets (tipsets that have this tipset as a parent)
let mut to_remove = Vec::new();
let mut descendants = Vec::new();

for (key, ts) in self.tipsets.iter() {
if ts.parents() == tipset.key() {
to_remove.push(key.clone());
descendants.push(ts.clone());
for (key, ts) in self.tipsets.iter() {
if ts.parents() == tipset.key() {
to_remove.push(key.clone());
descendants.push(ts.clone());
}
}
}

// Remove bad tipsets from the map
for key in to_remove {
self.tipsets.remove(&key);
}
// Remove bad tipsets from the map
for key in to_remove {
self.tipsets.remove(&key);
}

// Recursively mark descendants as bad
for descendant in descendants {
self.mark_bad_tipset(descendant, reason.clone());
// Mark descendants as bad
stack.extend(descendants);
}
}

Expand Down
Loading