Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Zsa swap bk #101

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
22ed1a0
Implement OrchardBundle enum
alexeykoren Oct 31, 2024
965a201
Clean up build warnings
alexeykoren Oct 31, 2024
f086799
Fix clippy warnings
alexeykoren Oct 31, 2024
7057e08
Remove OrchardZsaAuth
alexeykoren Nov 15, 2024
2b484bb
Fix zfuture
alexeykoren Nov 18, 2024
2e576ea
Fix client_backend
alexeykoren Nov 18, 2024
8b40281
Disable wasm CI target
alexeykoren Nov 19, 2024
ae6d2c2
Better handle errors
alexeykoren Dec 12, 2024
a8c8280
Re-enable CI wasm check
alexeykoren Dec 12, 2024
d3312c7
Switch to zsa1
alexeykoren Dec 12, 2024
63fedaa
Revert "Use correct Nu7 branch_id"
alexeykoren Dec 16, 2024
ffd6db0
Fmt
alexeykoren Dec 16, 2024
3f205c4
Downgrade Rust version
alexeykoren Dec 16, 2024
72b117b
Rebase to latest zsa1
alexeykoren Jan 26, 2025
fcc7c76
Implement OrchardBundle enum
alexeykoren Oct 31, 2024
0a682a0
Add swap bundle to enum
alexeykoren Nov 11, 2024
1a6e223
Add swapbundle basics
alexeykoren Jan 2, 2025
9149f73
Optimize imports
alexeykoren Jan 2, 2025
609834b
Add swap branch
alexeykoren Jan 2, 2025
a8272ae
Change swap zcash_unstable to nu6
alexeykoren Jan 2, 2025
2290253
Add SwapBundle digest
alexeykoren Jan 2, 2025
fa8d7ff
Add action groups
alexeykoren Jan 3, 2025
5c8b57d
Rework serialization (WIP)
alexeykoren Feb 3, 2025
727585c
Use updated Orchard
alexeykoren Feb 12, 2025
7581bea
Rebase
alexeykoren Feb 15, 2025
c6ece35
Add more tests
alexeykoren Feb 16, 2025
b4226a2
Add reference notes in tests
alexeykoren Feb 18, 2025
9bc3ff8
Fix lints and formatting
alexeykoren Feb 18, 2025
71994cb
Rollback dependencies
alexeykoren Feb 18, 2025
84399ba
Regenerate protobuffs
alexeykoren Feb 18, 2025
c8dac17
Update Orchard
alexeykoren Feb 18, 2025
9a5a5f8
Fix bundle type in test
alexeykoren Feb 24, 2025
dec0362
Copy dummy methods from Orchard
alexeykoren Feb 24, 2025
d106f9f
Add rustfmt settings file
alexeykoren Feb 24, 2025
e9a16b2
Specify fmt config path
alexeykoren Feb 24, 2025
c1b0f2c
Revert "Specify fmt config path"
alexeykoren Feb 25, 2025
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
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ codegen-units = 1
[patch.crates-io]
zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/zcash_note_encryption", branch = "zsa1" }
sapling = { package = "sapling-crypto", version = "0.1.3", git = "https://github.com/QED-it/sapling-crypto", branch = "zsa1" }
orchard = { version = "0.8.0", git = "https://github.com/QED-it/orchard", rev = "3dbdbc52c6e2ffeca015ae6eb80ad7f1c870384d" }
orchard = { version = "0.8.0", git = "https://github.com/QED-it/orchard", branch = "zsa_swap_spendauth_clone" }
46 changes: 45 additions & 1 deletion components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ impl Parameters for MainNetwork {
NetworkUpgrade::Nu6 => Some(BlockHeight(2_726_400)),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(2_726_401)),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap => Some(BlockHeight(2_726_402)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
Expand Down Expand Up @@ -390,6 +392,8 @@ impl Parameters for TestNetwork {
NetworkUpgrade::Nu6 => Some(BlockHeight(2_976_000)),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(2_976_001)),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap => Some(BlockHeight(2_976_002)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
Expand Down Expand Up @@ -421,6 +425,8 @@ impl Parameters for RegtestNetwork {
NetworkUpgrade::Nu6 => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
Expand Down Expand Up @@ -497,6 +503,11 @@ pub enum NetworkUpgrade {
/// [Nu7]: https://z.cash/upgrade/nu7/
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
Nu7,
/// The [Swap] network upgrade.
///
/// [Swap]:
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
Swap,
/// The ZFUTURE network upgrade.
///
/// This upgrade is expected never to activate on mainnet;
Expand All @@ -521,6 +532,8 @@ impl fmt::Display for NetworkUpgrade {
NetworkUpgrade::Nu6 => write!(f, "Nu6"),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => write!(f, "Nu7"),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap => write!(f, "Swap"),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => write!(f, "ZFUTURE"),
}
Expand All @@ -540,6 +553,8 @@ impl NetworkUpgrade {
NetworkUpgrade::Nu6 => BranchId::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => BranchId::Nu7,
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap => BranchId::Swap,
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => BranchId::ZFuture,
}
Expand All @@ -561,6 +576,8 @@ const UPGRADES_IN_ORDER: &[NetworkUpgrade] = &[
NetworkUpgrade::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7,
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
NetworkUpgrade::Swap,
];

/// The "grace period" defined in [ZIP 212].
Expand Down Expand Up @@ -603,6 +620,9 @@ pub enum BranchId {
/// The consensus rules deployed by [`NetworkUpgrade::Nu7`].
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
Nu7,
/// The consensus rules deployed by [`NetworkUpgrade::Swap`].
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
Swap,
/// Candidates for future consensus rules; this branch will never
/// activate on mainnet.
#[cfg(zcash_unstable = "zfuture")]
Expand All @@ -627,9 +647,13 @@ impl TryFrom<u32> for BranchId {
0xc8e7_1055 => Ok(BranchId::Nu6),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
0x7719_0ad8 => Ok(BranchId::Nu7),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
0x8888_8888 => Ok(BranchId::Swap),
#[cfg(zcash_unstable = "zfuture")]
0xffff_ffff => Ok(BranchId::ZFuture),
_ => Err("Unknown consensus branch ID"),
_ => Err(Box::leak(
format!("Unknown consensus branch ID: {:08x}", value).into_boxed_str(),
)),
}
}
}
Expand All @@ -648,6 +672,8 @@ impl From<BranchId> for u32 {
BranchId::Nu6 => 0xc8e7_1055,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
BranchId::Nu7 => 0x7719_0ad8,
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
BranchId::Swap => 0x8888_8888,
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => 0xffff_ffff,
}
Expand Down Expand Up @@ -724,6 +750,10 @@ impl BranchId {
BranchId::Nu7 => params
.activation_height(NetworkUpgrade::Nu7)
.map(|lower| (lower, upper_bound(lower, params))),
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
BranchId::Swap => params
.activation_height(NetworkUpgrade::Swap)
.map(|lower| (lower, upper_bound(lower, params))),
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => params
.activation_height(NetworkUpgrade::ZFuture)
Expand Down Expand Up @@ -753,6 +783,13 @@ fn upper_bound<P: Parameters>(target_height: BlockHeight, params: &P) -> Option<
.filter(|&nu_height| nu_height > target_height)
.or(upper);
}
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
{
upper = params
.activation_height(NetworkUpgrade::Swap)
.filter(|&nu_height| nu_height > target_height)
.or(upper);
}
#[cfg(zcash_unstable = "zfuture")]
{
upper = params
Expand Down Expand Up @@ -783,6 +820,8 @@ pub mod testing {
BranchId::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
BranchId::Nu7,
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
BranchId::Swap,
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture,
])
Expand Down Expand Up @@ -886,5 +925,10 @@ mod tests {
BranchId::for_height(&MAIN_NETWORK, BlockHeight(2_726_401)),
BranchId::Nu7,
);
#[cfg(zcash_unstable = "nu6" /* TODO swap */ )]
assert_eq!(
BranchId::for_height(&MAIN_NETWORK, BlockHeight(2_726_402)),
BranchId::Swap,
);
}
}
9 changes: 9 additions & 0 deletions components/zcash_protocol/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ impl ZatBalance {
}
}

impl Sum for ZatBalance {
fn sum<I>(iter: I) -> Self
where
I: Iterator<Item = Self>,
{
iter.fold(ZatBalance(0), |acc, item| ZatBalance(acc.0 + item.0))
}
}

impl TryFrom<i64> for ZatBalance {
type Error = BalanceError;

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.70.0"
channel = "1.71.0"
components = [ "clippy", "rustfmt" ]
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reorder_imports = false
1 change: 1 addition & 0 deletions zcash_primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ nonempty.workspace = true
orchard.workspace = true
sapling.workspace = true
zcash_spec.workspace = true
pasta_curves.workspace = true

# - Note Commitment Trees
incrementalmerkletree = { workspace = true, features = ["legacy-api"] }
Expand Down
Loading
Loading