Skip to content

Comments

clean up for zingolib v3.0.0 rc#2194

Merged
zancas merged 9 commits intozingolabs:devfrom
Oscar-Pepper:clean_up_for_zingolib_v3-0-0_rc
Feb 23, 2026
Merged

clean up for zingolib v3.0.0 rc#2194
zancas merged 9 commits intozingolabs:devfrom
Oscar-Pepper:clean_up_for_zingolib_v3-0-0_rc

Conversation

@Oscar-Pepper
Copy link
Contributor

@Oscar-Pepper Oscar-Pepper commented Feb 20, 2026

  • reverts naming to use wallet birthday as the code reads much clearer. to avoid previous confusion with sapling activation heights, sync now returns an error if the birthday returned is lower than the sapling activation height.
  • fixed a var name and comments that were misleading or incorrect
  • added scan range truncation, preventing truncated wallets to still have last_known_chain_heights higher than the current chain_height

@Oscar-Pepper Oscar-Pepper requested a review from zancas February 20, 2026 04:36
merge_scan_ranges(sync_state, ScanPriority::ChainTip);

let verification_height = sync_state
let reorg_detection_start_height = sync_state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this name!!!

Copy link
Member

@zancas zancas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left non-blocking comments, with 1 exception, why is truncate_scan_ranges a free fn that takes a &mut instead of a method of SyncState?

Everything else looks good to me. I like the renames, and erroring below Sapling.


/// Splits the range containing [`truncate_height` + 1] and removes all ranges containing block heights above
/// `truncate_height`.
pub(super) fn truncate_scan_ranges(truncate_height: BlockHeight, sync_state: &mut SyncState) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define this as a method of a SyncState?

#[error(
"birthday {0} below sapling activation height {1}. pre-sapling wallets are not supported!"
)]
BirthdayBelowSapling(u32, u32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am +1 on this.

/// * the number of blocks AHEAD of proxy_reported_chain_height allowed
/// (2) Sapling Epoch Height:
/// * the maximum number of blocks the wallet can truncate during re-org detection
/// (2) Sapling Activation Height:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Err(SyncError::WalletError(
crate::mocks::MockWalletError::AnErrorVariant(ref s)
)) if s == test_error
} else if birthday < sapling_activation_height {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am +1 on this.

));
}

mod last_known_chain_height {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all these tests removed? Are they included elsewhere?

Ok(())
}

/// Compares the wallet birthday to sapling activation height and returns the highest block height.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

}

#[cfg(test)]
mod test {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh.. OK.

)) if s == test_error
));
}
#[ignore = "in progress"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update these.

@Oscar-Pepper
Copy link
Contributor Author

I left non-blocking comments, with 1 exception, why is truncate_scan_ranges a free fn that takes a &mut instead of a method of SyncState?

Everything else looks good to me. I like the renames, and erroring below Sapling.

I'm not sure which changes have been requested for merge. Regarding the truncate being a method on sync state, there was a bunch of trade-offs I considered with this and decided a functional architecture worked best for the library. This allows us to keep SyncState succinct in the 'wallet' module (public APi for use in consumer wallet structs) and keep all the state logic cleanly separated. I also think it would be confusing to have a bunch of SyncState impl spread across the library... I like them to be directly under the struct or in clean submodules so consumers can clearly see all methods/functionality of a type. There is also the fact that many state fns don't just operate on the SyncState so I think there is more consistency this way. There are possibly other reasons but it's a while since I decided to go this way. If you have a counter argument for a benefit of object-oriented I have missed we can discuss

@zancas
Copy link
Member

zancas commented Feb 23, 2026

I think the reasoning you offer here is very useful. I haven't carefully considered tradeoffs in this space, but I think it's very worthwhile to capture our thinking somewhere.

@zancas zancas merged commit 36f0032 into zingolabs:dev Feb 23, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants