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: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
needs:
- test
# - test
- distributions
outputs:
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
Expand Down
2 changes: 1 addition & 1 deletion components/chainhook-sdk/src/indexer/fork_scratch_pad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl ForkScratchPad {
},
));
}
if let Ok(divergence) = canonical_segment.try_identify_divergence(other_segment, false, ctx)
if let Ok(divergence) = canonical_segment.try_identify_divergence(other_segment, ctx)
{
if divergence.block_ids_to_rollback.is_empty() {
let mut new_headers = vec![];
Expand Down
28 changes: 9 additions & 19 deletions components/chainhook-sdk/src/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ pub mod fork_scratch_pad;
pub mod stacks;

use crate::{
chainhooks::types::PoxConfig,
indexer::database::BlocksDatabaseAccess,
try_debug,
utils::{AbstractBlock, Context},
chainhooks::types::PoxConfig, indexer::database::BlocksDatabaseAccess, try_debug, try_warn, utils::{AbstractBlock, Context}
};

use chainhook_types::{
Expand Down Expand Up @@ -364,7 +361,6 @@ impl ChainSegment {
fn try_identify_divergence(
&self,
other_segment: &ChainSegment,
allow_reset: bool,
ctx: &Context,
) -> Result<ChainSegmentDivergence, ChainSegmentIncompatibility> {
let mut common_root = None;
Expand All @@ -384,22 +380,16 @@ impl ChainSegment {
}
block_ids_to_rollback.push(cursor_segment_1.clone());
}
ctx.try_log(|logger| {
slog::debug!(logger, "Blocks to rollback: {:?}", block_ids_to_rollback)
});
ctx.try_log(|logger| slog::debug!(logger, "Blocks to apply: {:?}", block_ids_to_apply));
try_debug!(ctx, "Blocks to rollback: {:?}", block_ids_to_rollback);
try_debug!(ctx, "Blocks to apply: {:?}", block_ids_to_apply);
block_ids_to_apply.reverse();
match common_root.take() {
Some(_common_root) => Ok(ChainSegmentDivergence {
block_ids_to_rollback,
block_ids_to_apply,
}),
None if allow_reset => Ok(ChainSegmentDivergence {
block_ids_to_rollback,
block_ids_to_apply,
}),
None => Err(ChainSegmentIncompatibility::Unknown),
if common_root.is_none() {
try_warn!(ctx, "No deep re-org common root found between {} and {}, returning incomplete divergence", self, other_segment);
}
Ok(ChainSegmentDivergence {
block_ids_to_rollback,
block_ids_to_apply,
})
}

fn try_append_block(
Expand Down
4 changes: 2 additions & 2 deletions components/chainhook-sdk/src/indexer/stacks/blocks_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ impl StacksBlockPool {
},
));
}
if let Ok(divergence) = canonical_segment.try_identify_divergence(other_segment, false, ctx)
if let Ok(divergence) = canonical_segment.try_identify_divergence(other_segment, ctx)
{
if divergence.block_ids_to_rollback.is_empty() {
let mut new_blocks = vec![];
Expand Down Expand Up @@ -1037,7 +1037,7 @@ impl StacksBlockPool {
}

if let Ok(divergence) =
new_canonical_segment.try_identify_divergence(previous_canonical_segment, true, ctx)
new_canonical_segment.try_identify_divergence(previous_canonical_segment, ctx)
{
if divergence.block_ids_to_rollback.is_empty() {
let mut new_microblocks = vec![];
Expand Down