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

ring 0.17.X upgrade #1318

Closed
Closed
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
635 changes: 375 additions & 260 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ members = [
resolver = "2"

[workspace.dependencies]
zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change" }
zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] }
zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change" }
zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change", features = ["transparent-inputs", "sapling", "orchard" ] }
zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496" }
zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] }
zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496" }
zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496", features = ["transparent-inputs", "sapling", "orchard" ] }
zcash_note_encryption = "0.4"
zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change" }
zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change" }
zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "always_require_change" }
zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496" }
zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496" }
zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", rev = "b323e16b54854920269c9f6b923c91c2e27b3496" }
sapling-crypto = "0.1.2"
orchard = "0.8"
zip32 = "0.1"
bip0039 = "0.11.0"

clap = "4.4"
tempdir = "0.3"
Expand All @@ -36,14 +37,14 @@ shardtree = "0.3"
build_utils = { path = "./build_utils" }
http = "0.2.4"
hyper = { version = "0.14", features = ["full"] }
hyper-rustls = { version = "0.23", features = ["http2"] }
hyper-rustls = { version = "0.25", features = ["http2"] }
http-body = "0.4.4"
tonic = {version = "0.10.0", features = ["tls", "tls-roots", "tls-webpki-roots"]}
prost = "0.12.0"
tower = { version = "0.4" }
hex = "0.4"
tokio-rustls = "0.23"
webpki-roots = "0.25"
tokio-rustls = "0.25"
webpki-roots = "0.26"
thiserror = "1.0.59"
nonempty = "0.7"
append-only-vec = { git = "https://github.com/zancas/append-only-vec.git", branch = "add_debug_impl" }
Expand Down
1 change: 1 addition & 0 deletions libtonode-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ serde_json = { workspace = true }
http.workspace = true
tempfile.workspace = true
tracing-subscriber.workspace = true
bip0039.workspace = true
14 changes: 8 additions & 6 deletions libtonode-tests/tests/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,10 @@ mod fast {
async fn diversification_deterministic_and_coherent() {
let (_regtest_manager, _cph, mut client_builder, regtest_network) =
scenarios::custom_clients_default().await;
let seed_phrase = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32])
.unwrap()
.to_string();
let seed_phrase =
zcash_primitives::zip339::Mnemonic::<bip0039::English>::from_entropy([1; 32])
.unwrap()
.to_string();
let recipient1 = client_builder
.build_client(seed_phrase, 0, false, regtest_network)
.await;
Expand Down Expand Up @@ -2635,9 +2636,10 @@ mod slow {
scenarios::custom_clients_default().await;
let faucet = client_builder.build_faucet(false, regtest_network).await;
faucet.do_sync(false).await.unwrap();
let seed_phrase_of_recipient1 = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32])
.unwrap()
.to_string();
let seed_phrase_of_recipient1 =
zcash_primitives::zip339::Mnemonic::<bip0039::English>::from_entropy([1; 32])
.unwrap()
.to_string();
let recipient1 = client_builder
.build_client(seed_phrase_of_recipient1, 0, false, regtest_network)
.await;
Expand Down
1 change: 1 addition & 0 deletions zingo-netutils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tonic.workspace = true
prost.workspace = true
thiserror.workspace = true
rustls-pemfile = { workspace = true }
rustls-pki-types = "1.7.0"

[features]
test-features = []
30 changes: 18 additions & 12 deletions zingo-netutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,26 @@ impl GrpcConnector {
.ok_or(GetClientError::InvalidAuthority)?
.clone();
if uri.scheme_str() == Some("https") {
let mut roots = RootCertStore::empty();
roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(
|anchor_ref| {
tokio_rustls::rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
anchor_ref.subject,
anchor_ref.spki,
anchor_ref.name_constraints,
)
},
));
// Much simpler than trying to feature-gate out the mut
#[allow(unused_mut)]
let mut roots = RootCertStore {
roots: webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
.map(|anchor| rustls_pki_types::TrustAnchor {
subject: rustls_pki_types::Der::from_slice(anchor.subject),
subject_public_key_info: rustls_pki_types::Der::from_slice(anchor.spki),
name_constraints: anchor
.name_constraints
.map(rustls_pki_types::Der::from_slice),
})
.collect(),
};

#[cfg(test)]
add_test_cert_to_roots(&mut roots);

let tls = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(roots)
.with_no_client_auth();
let connector = tower::ServiceBuilder::new()
Expand Down Expand Up @@ -158,9 +162,11 @@ impl GrpcConnector {

#[cfg(test)]
fn add_test_cert_to_roots(roots: &mut RootCertStore) {
use rustls_pki_types::CertificateDer;

const TEST_PEMFILE_PATH: &str = "test-data/localhost.pem";
let fd = std::fs::File::open(TEST_PEMFILE_PATH).unwrap();
let mut buf = std::io::BufReader::new(&fd);
let certs = rustls_pemfile::certs(&mut buf).unwrap();
roots.add_parsable_certificates(&certs);
roots.add_parsable_certificates(certs.iter().map(|cert| CertificateDer::from_slice(cert)));
}
1 change: 1 addition & 0 deletions zingolib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ tempdir = {workspace = true, optional = true }
tempfile = {workspace = true, optional = true }
dirs.workspace = true
log4rs.workspace = true
bip0039.workspace = true

[dev-dependencies]
portpicker = { workspace = true }
Expand Down
7 changes: 4 additions & 3 deletions zingolib/src/testvectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ pub mod seeds {
"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread";
#[test]
fn validate_seeds() {
let abandon_art_seed = zcash_primitives::zip339::Mnemonic::from_entropy([0; 32])
.unwrap()
.to_string();
let abandon_art_seed =
zcash_primitives::zip339::Mnemonic::<bip0039::language::English>::from_entropy([0; 32])
.unwrap()
.to_string();
assert_eq!(ABANDON_ART_SEED, abandon_art_seed);
// TODO user get_zaddr_from_bip39seed to generate this address from that seed.
}
Expand Down
2 changes: 1 addition & 1 deletion zingolib/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl LightWallet {
);
}
WalletBase::MnemonicPhraseAndIndex(phrase, position) => {
let mnemonic = Mnemonic::from_phrase(phrase)
let mnemonic = Mnemonic::<bip0039::English>::from_phrase(phrase)
.and_then(|m| Mnemonic::from_entropy(m.entropy()))
.map_err(|e| {
Error::new(
Expand Down
16 changes: 14 additions & 2 deletions zingolib/src/wallet/disk/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ async fn loaded_wallet_assert(wallet: LightWallet, expected_balance: u64, num_ad
.unwrap(),
0,
);
assert_eq!(wallet.mnemonic(), Some(&expected_mnemonic));
assert_eq!(
wallet
.mnemonic()
.map(|(mnemonic, account_index)| (mnemonic.phrase(), account_index)),
Some(&expected_mnemonic)
.map(|(mnemonic, account_number)| (mnemonic.phrase(), account_number))
);

let expected_wc = crate::wallet::keys::unified::WalletCapability::new_from_phrase(
&wallet.transaction_context.config,
Expand Down Expand Up @@ -190,7 +196,13 @@ async fn reload_wallet_from_buffer() {
Mnemonic::from_phrase(CHIMNEY_BETTER_SEED.to_string()).unwrap(),
0,
);
assert_eq!(wallet.mnemonic(), Some(&expected_mnemonic));
assert_eq!(
wallet
.mnemonic()
.map(|(mnemonic, account_index)| (mnemonic.phrase(), account_index)),
Some(&expected_mnemonic)
.map(|(mnemonic, account_index)| (mnemonic.phrase(), account_index))
);

let expected_wc = WalletCapability::new_from_phrase(
&mid_client.wallet.transaction_context.config,
Expand Down
Loading