Skip to content

Commit 9302156

Browse files
committed
fix(cardano-chain-follower): new fork
Signed-off-by: bkioshn <[email protected]>
1 parent 557e20c commit 9302156

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

rust/cardano-chain-follower/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mithril-client = { version = "0.10.4", default-features = false, features = [
1919
"full",
2020
"num-integer-backend",
2121
] }
22-
cardano-blockchain-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250109-00" }
22+
cardano-blockchain-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "fix/fork" }
2323
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250108-00" }
2424

2525
thiserror = "1.0.69"

rust/cardano-chain-follower/examples/follow_chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ async fn follow_for(network: Network, matches: ArgMatches) {
190190
// If these become true, we will show all blocks from the follower.
191191
follow_all = follow_all
192192
|| (!chain_update.immutable() && all_live_blocks)
193-
|| ((chain_update.data.fork() > 1.into()) && all_tip_blocks);
193+
|| (chain_update.data.fork().is_live() && all_tip_blocks);
194194

195195
// Don't know if this update will show or not, so say it didn't.
196196
last_update_shown = false;

rust/cardano-chain-follower/src/chain_sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ async fn live_sync_backfill(
368368

369369
while let Some(block_data) = peer.blockfetch().recv_while_streaming().await? {
370370
// Backfilled blocks get placed in the oldest fork currently on the live-chain.
371-
let block = MultiEraBlock::new(cfg.chain, block_data, &previous_point, 1.into())
371+
let block = MultiEraBlock::new(cfg.chain, block_data, &previous_point, Fork::BACKFILL)
372372
.with_context(|| {
373373
format!(
374374
"Failed to decode block data. previous: {previous_point:?}, range: {range_msg}"
@@ -534,7 +534,7 @@ pub(crate) async fn chain_sync(cfg: ChainSyncConfig, rx: mpsc::Receiver<MithrilU
534534
// Live Fill data starts at fork 1.
535535
// Immutable data from a mithril snapshot is fork 0.
536536
// Live backfill is always Fork 1.
537-
let mut fork_count: Fork = 2.into();
537+
let mut fork_count: Fork = Fork::FIRST_LIVE;
538538

539539
loop {
540540
// We never have a connection if we end up around the loop, so make a new one.

rust/cardano-chain-follower/src/chain_sync_live_chains.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static PEER_TIP: LazyLock<SkipMap<Network, Point>> = LazyLock::new(|| {
4545
map
4646
});
4747

48+
/// Initial slot age to probe.
49+
const INITIAL_SLOT_PROBE_AGE: u64 = 40;
50+
4851
/// Set the last TIP received from the peer.
4952
fn update_peer_tip(chain: Network, tip: Point) {
5053
PEER_TIP.insert(chain, tip);
@@ -207,7 +210,7 @@ impl ProtectedLiveChainBlockList {
207210
let mut rollback_size: u64 = 0;
208211

209212
// We are NOT contiguous, so check if we can become contiguous with a rollback.
210-
debug!("Detected non-contiguous block, rolling back. Fork: {fork_count:?}");
213+
debug!("Detected non-contiguous block, rolling back. Fork: {fork_count}");
211214

212215
// First check if the previous is >= the earliest block in the live chain.
213216
// This is because when we start syncing we could rollback earlier than our
@@ -344,7 +347,7 @@ impl ProtectedLiveChainBlockList {
344347
}
345348

346349
// Now find points based on an every increasing Slot age.
347-
let mut slot_age: Slot = 40.into();
350+
let mut slot_age: Slot = INITIAL_SLOT_PROBE_AGE.into();
348351
let reference_slot = entry.value().point().slot_or_default();
349352
let mut previous_point = entry.value().point();
350353

rust/cardano-chain-follower/src/follow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl ChainFollower {
101101
self.previous = self.current.clone();
102102
// debug!("Post Previous update 3 : {:?}", self.previous);
103103
self.current = next.point();
104-
self.fork = 0.into(); // Mithril Immutable data is always Fork 0.
104+
self.fork = Fork::IMMUTABLE; // Mithril Immutable data is always Fork 0.
105105
let update = ChainUpdate::new(chain_update::Kind::Block, false, next);
106106
return Some(update);
107107
}

0 commit comments

Comments
 (0)