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
277 changes: 1 addition & 276 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ resolver = "2"

[workspace.dependencies]

# content
zebra-chain = "5.0"

# network
http = "1.1.0"
http-body = "1"
Expand All @@ -21,5 +18,5 @@ tonic = { version = "0.14", features = [
tower = { version = "0.5" }
webpki-roots = "0.25"

# exceptions
# error
thiserror = "1.0.64"
12 changes: 1 addition & 11 deletions CHANGELOG.md → zingo-netutils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

### Removed

## [0.2.0] - 2026-02-12

### Deprecated

### Added

### Changed

- Support for Zebra 4.1.0 through `zebra-chain = "5.0"`
- Bump `tonic` from `0.13` to `0.14`, with `tls-webpki-roots` enabled.

### Removed

## [0.1.0]
## [1.1.0]

NOT PUBLISHED
2 changes: 1 addition & 1 deletion zingo-netutils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror.workspace = true
tokio-rustls.workspace = true
tonic.workspace = true
tower.workspace = true
webpki-roots = "0.25"
webpki-roots.workspace = true

zcash_client_backend = { version = "0.21", features = [
"lightwalletd-tonic",
Expand Down
39 changes: 39 additions & 0 deletions zingo_common_components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Deprecated

### Added

- `protocol::NetworkType`: replaces zebra-chain `NetworkKind` type.
- `protocol::ActivationHeights`: replaces zebra-chain `ConfiguredActivationHeights` type.
- `protocol::ActivationHeightsBuilder`

### Changed

### Removed

- `protocol::activation_heights` mod and `for_test` child module: results in removal of zebra-chain dependency.

## [0.2.0] - 2026-02-12

### Deprecated

### Added

### Changed

- Support for Zebra 4.1.0 through `zebra-chain = "5.0"`
- Bump `tonic` from `0.13` to `0.14`, with `tls-webpki-roots` enabled.

### Removed

## [0.1.0]

NOT PUBLISHED
3 changes: 0 additions & 3 deletions zingo_common_components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ repository = "https://github.com/zingolabs/zingo-common.git"
version = "0.2.0"
edition = "2024"
license = "MIT"
[features]
for_test = []

[dependencies]
zebra-chain = { workspace = true }
7 changes: 7 additions & 0 deletions zingo_common_components/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
//! Crate for common types used by zingolabs crates.
//!
//! Types in this crate are intended to be suitable for use in the public API of other crates so must only include types
//! that have a stable public API that will only increase major semver version in rare cases.

#![warn(missing_docs)]

pub mod protocol;
246 changes: 245 additions & 1 deletion zingo_common_components/src/protocol.rs
Original file line number Diff line number Diff line change
@@ -1 +1,245 @@
pub mod activation_heights;
//! Module for types associated with the zcash protocol and consensus.

/// Network types.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NetworkType {
/// Mainnet
Mainnet,
/// Testnet
Testnet,
/// Regtest
Regtest(ActivationHeights),
}

impl std::fmt::Display for NetworkType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let chain = match self {
NetworkType::Mainnet => "mainnet",
NetworkType::Testnet => "testnet",
NetworkType::Regtest(_) => "regtest",
};
write!(f, "{chain}")
}
}

/// Network upgrade activation heights for custom testnet and regtest network configuration.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ActivationHeights {
overwinter: Option<u32>,
sapling: Option<u32>,
blossom: Option<u32>,
heartwood: Option<u32>,
canopy: Option<u32>,
nu5: Option<u32>,
nu6: Option<u32>,
nu6_1: Option<u32>,
nu7: Option<u32>,
}

impl Default for ActivationHeights {
fn default() -> Self {
Self::builder()
.set_overwinter(Some(1))
.set_sapling(Some(1))
.set_blossom(Some(1))
.set_heartwood(Some(1))
.set_canopy(Some(1))
.set_nu5(Some(1))
.set_nu6(Some(1))
.set_nu6_1(Some(1))
.set_nu7(None)
.build()
}
}

impl ActivationHeights {
/// Constructs new builder.
pub fn builder() -> ActivationHeightsBuilder {
ActivationHeightsBuilder::new()
}

/// Returns overwinter network upgrade activation height.
pub fn overwinter(&self) -> Option<u32> {
self.overwinter
}

/// Returns sapling network upgrade activation height.
pub fn sapling(&self) -> Option<u32> {
self.sapling
}

/// Returns blossom network upgrade activation height.
pub fn blossom(&self) -> Option<u32> {
self.blossom
}

/// Returns heartwood network upgrade activation height.
pub fn heartwood(&self) -> Option<u32> {
self.heartwood
}

/// Returns canopy network upgrade activation height.
pub fn canopy(&self) -> Option<u32> {
self.canopy
}

/// Returns nu5 network upgrade activation height.
pub fn nu5(&self) -> Option<u32> {
self.nu5
}

/// Returns nu6 network upgrade activation height.
pub fn nu6(&self) -> Option<u32> {
self.nu6
}

/// Returns nu6.1 network upgrade activation height.
pub fn nu6_1(&self) -> Option<u32> {
self.nu6_1
}

/// Returns nu7 network upgrade activation height.
pub fn nu7(&self) -> Option<u32> {
self.nu7
}
}

/// Leverages a builder method to avoid new network upgrades from causing breaking changes to the public API.
pub struct ActivationHeightsBuilder {
overwinter: Option<u32>,
sapling: Option<u32>,
blossom: Option<u32>,
heartwood: Option<u32>,
canopy: Option<u32>,
nu5: Option<u32>,
nu6: Option<u32>,
nu6_1: Option<u32>,
nu7: Option<u32>,
}

impl Default for ActivationHeightsBuilder {
fn default() -> Self {
Self::new()
}
}

impl ActivationHeightsBuilder {
/// Constructs a builder with all fields set to `None`.
pub fn new() -> Self {
Self {
overwinter: None,
sapling: None,
blossom: None,
heartwood: None,
canopy: None,
nu5: None,
nu6: None,
nu6_1: None,
nu7: None,
}
}

/// Set `overwinter` field.
pub fn set_overwinter(mut self, height: Option<u32>) -> Self {
self.overwinter = height;

self
}

/// Set `sapling` field.
pub fn set_sapling(mut self, height: Option<u32>) -> Self {
self.sapling = height;

self
}

/// Set `blossom` field.
pub fn set_blossom(mut self, height: Option<u32>) -> Self {
self.blossom = height;

self
}

/// Set `heartwood` field.
pub fn set_heartwood(mut self, height: Option<u32>) -> Self {
self.heartwood = height;

self
}

/// Set `canopy` field.
pub fn set_canopy(mut self, height: Option<u32>) -> Self {
self.canopy = height;

self
}

/// Set `nu5` field.
pub fn set_nu5(mut self, height: Option<u32>) -> Self {
self.nu5 = height;

self
}

/// Set `nu6` field.
pub fn set_nu6(mut self, height: Option<u32>) -> Self {
self.nu6 = height;

self
}

/// Set `nu6_1` field.
pub fn set_nu6_1(mut self, height: Option<u32>) -> Self {
self.nu6_1 = height;

self
}

/// Set `nu7` field.
pub fn set_nu7(mut self, height: Option<u32>) -> Self {
self.nu7 = height;

self
}

/// Builds `ActivationHeights` with assertions to ensure all earlier network upgrades are active with an activation
/// height equal to or lower than the later network upgrades.
pub fn build(self) -> ActivationHeights {
if let Some(b) = self.sapling {
assert!(self.overwinter.is_some_and(|a| a <= b));
}
if let Some(b) = self.blossom {
assert!(self.sapling.is_some_and(|a| a <= b));
}
if let Some(b) = self.heartwood {
assert!(self.blossom.is_some_and(|a| a <= b));
}
if let Some(b) = self.canopy {
assert!(self.heartwood.is_some_and(|a| a <= b));
}
if let Some(b) = self.nu5 {
assert!(self.canopy.is_some_and(|a| a <= b));
}
if let Some(b) = self.nu6 {
assert!(self.nu5.is_some_and(|a| a <= b));
}
if let Some(b) = self.nu6_1 {
assert!(self.nu6.is_some_and(|a| a <= b));
}
if let Some(b) = self.nu7 {
assert!(self.nu6_1.is_some_and(|a| a <= b));
}

ActivationHeights {
overwinter: self.overwinter,
sapling: self.sapling,
blossom: self.blossom,
heartwood: self.heartwood,
canopy: self.canopy,
nu5: self.nu5,
nu6: self.nu6,
nu6_1: self.nu6_1,
nu7: self.nu7,
}
}
}
2 changes: 0 additions & 2 deletions zingo_common_components/src/protocol/activation_heights.rs

This file was deleted.

Loading