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

merge queue: embarking main (0d50d97) and [#6536 + #6521] together #6539

Closed
wants to merge 8 commits into from
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
307 changes: 235 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ skip-tree = [
# wait for zcash_primitives to remove duplicated dependencies
{ name = "block-buffer", version = "=0.9.0" },

# wait for zcash_address to upgrade
{ name = "bech32", version = "=0.8.1"},

# wait for zcash_proofs to upgrade `directories`
{ name = "dirs-sys", version = "=0.3.7"},

# zebra-utils dependencies

# wait for structopt upgrade (or upgrade to clap 3)
Expand Down
14 changes: 7 additions & 7 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ blake2s_simd = "1.0.1"
bs58 = { version = "0.4.0", features = ["check"] }
byteorder = "1.4.3"
equihash = "0.2.0"
group = "0.12.0"
group = "0.13.0"
incrementalmerkletree = "0.3.1"
jubjub = "0.9.0"
jubjub = "0.10.0"
lazy_static = "1.4.0"
primitive-types = "0.11.1"
rand_core = "0.6.4"
Expand All @@ -55,12 +55,12 @@ uint = "0.9.5"
x25519-dalek = { version = "2.0.0-pre.1", features = ["serde"] }

# ECC deps
halo2 = { package = "halo2_proofs", version = "0.2.0" }
orchard = "0.3.0"
halo2 = { package = "halo2_proofs", version = "0.3.0" }
orchard = "0.4.0"
zcash_encoding = "0.2.0"
zcash_history = "0.3.0"
zcash_note_encryption = "0.2.0"
zcash_primitives = { version = "0.10.2", features = ["transparent-inputs"] }
zcash_note_encryption = "0.3.0"
zcash_primitives = { version = "0.11.0", features = ["transparent-inputs"] }

# Time
chrono = { version = "0.4.24", default-features = false, features = ["clock", "std", "serde"] }
Expand All @@ -85,7 +85,7 @@ rayon = "1.7.0"

# ZF deps
ed25519-zebra = "3.1.0"
redjubjub = "0.5.0"
redjubjub = "0.7.0"
reddsa = "0.5.0"

# Experimental feature getblocktemplate-rpcs
Expand Down
17 changes: 10 additions & 7 deletions zebra-chain/src/orchard/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//! Randomised data generation for Orchard types.

use group::{ff::PrimeField, prime::PrimeCurveAffine};
use halo2::{arithmetic::FieldExt, pasta::pallas};
use proptest::{arbitrary::any, array, collection::vec, prelude::*};

use group::{
ff::{FromUniformBytes, PrimeField},
prime::PrimeCurveAffine,
};
use halo2::pasta::pallas;
use reddsa::{orchard::SpendAuth, Signature, SigningKey, VerificationKey, VerificationKeyBytes};

use proptest::{arbitrary::any, array, collection::vec, prelude::*};

use super::{
keys::*, note, tree, Action, AuthorizedAction, Flags, NoteCommitment, ValueCommitment,
};
Expand Down Expand Up @@ -42,7 +45,7 @@ impl Arbitrary for note::Nullifier {
(vec(any::<u8>(), 64))
.prop_map(|bytes| {
let bytes = bytes.try_into().expect("vec is the correct length");
Self::try_from(pallas::Scalar::from_bytes_wide(&bytes).to_repr())
Self::try_from(pallas::Scalar::from_uniform_bytes(&bytes).to_repr())
.expect("a valid generated nullifier")
})
.boxed()
Expand Down Expand Up @@ -98,7 +101,7 @@ impl Arbitrary for SpendAuthVerificationKeyBytes {
.prop_map(|bytes| {
let bytes = bytes.try_into().expect("vec is the correct length");
// Convert to a scalar
let sk_scalar = pallas::Scalar::from_bytes_wide(&bytes);
let sk_scalar = pallas::Scalar::from_uniform_bytes(&bytes);
// Convert that back to a (canonical) encoding
let sk_bytes = sk_scalar.to_repr();
// Decode it into a signing key
Expand Down Expand Up @@ -129,7 +132,7 @@ impl Arbitrary for tree::Root {
(vec(any::<u8>(), 64))
.prop_map(|bytes| {
let bytes = bytes.try_into().expect("vec is the correct length");
Self::try_from(pallas::Base::from_bytes_wide(&bytes).to_repr())
Self::try_from(pallas::Base::from_uniform_bytes(&bytes).to_repr())
.expect("a valid generated Orchard note commitment tree root")
})
.boxed()
Expand Down
10 changes: 7 additions & 3 deletions zebra-chain/src/orchard/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

use std::{fmt, io};

use group::{ff::PrimeField, prime::PrimeCurveAffine, GroupEncoding};
use group::{
ff::{FromUniformBytes, PrimeField},
prime::PrimeCurveAffine,
GroupEncoding,
};
use halo2::{
arithmetic::{Coordinates, CurveAffine, FieldExt},
arithmetic::{Coordinates, CurveAffine},
pasta::pallas,
};
use lazy_static::lazy_static;
Expand All @@ -29,7 +33,7 @@ where
let mut bytes = [0u8; 64];
csprng.fill_bytes(&mut bytes);
// pallas::Scalar::from_bytes_wide() reduces the input modulo q_P under the hood.
pallas::Scalar::from_bytes_wide(&bytes)
pallas::Scalar::from_uniform_bytes(&bytes)
}

/// The randomness used in the Simsemilla hash for note commitment.
Expand Down
5 changes: 3 additions & 2 deletions zebra-chain/src/sapling/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::convert::TryInto;
//! Randomised data generation for sapling types.

use group::Group;
use jubjub::{AffinePoint, ExtendedPoint};
use proptest::{arbitrary::any, collection::vec, prelude::*};
use rand::SeedableRng;
use rand_chacha::ChaChaRng;

use proptest::{arbitrary::any, collection::vec, prelude::*};

use crate::primitives::Groth16Proof;

use super::{
Expand Down
37 changes: 23 additions & 14 deletions zebra-chain/src/transaction/unmined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,34 @@ mod zip317;
/// Contributes to the randomized, weighted eviction of transactions from the
/// mempool when it reaches a max size, also based on the total cost.
///
/// # Standard Rule
///
/// > Each transaction has a cost, which is an integer defined as:
/// >
/// > max(serialized transaction size in bytes, 4000)
/// > max(memory size in bytes, 10000)
/// >
/// > The memory size is an estimate of the size that a transaction occupies in the
/// > memory of a node. It MAY be approximated as the serialized transaction size in
/// > bytes.
/// >
/// > ...
/// >
/// > The threshold 4000 for the cost function is chosen so that the size in bytes
/// > of a typical fully shielded Sapling transaction (with, say, 2 shielded outputs
/// > and up to 5 shielded inputs) will fall below the threshold. This has the effect
/// > The threshold 10000 for the cost function is chosen so that the size in bytes of
/// > a minimal fully shielded Orchard transaction with 2 shielded actions (having a
/// > serialized size of 9165 bytes) will fall below the threshold. This has the effect
/// > of ensuring that such transactions are not evicted preferentially to typical
/// > transparent transactions because of their size.
/// > transparent or Sapling transactions because of their size.
///
/// [ZIP-401]: https://zips.z.cash/zip-0401
pub const MEMPOOL_TRANSACTION_COST_THRESHOLD: u64 = 4000;
pub const MEMPOOL_TRANSACTION_COST_THRESHOLD: u64 = 10_000;

/// When a transaction pays a fee less than the conventional fee,
/// this low fee penalty is added to its cost for mempool eviction.
///
/// See [VerifiedUnminedTx::eviction_weight()] for details.
const MEMPOOL_TRANSACTION_LOW_FEE_PENALTY: u64 = 16_000;
///
/// [ZIP-401]: https://zips.z.cash/zip-0401
const MEMPOOL_TRANSACTION_LOW_FEE_PENALTY: u64 = 40_000;

/// A unique identifier for an unmined transaction, regardless of version.
///
Expand Down Expand Up @@ -369,9 +379,7 @@ impl VerifiedUnminedTx {
/// and signature verification; networking overheads; size of in-memory data
/// structures).
///
/// > Each transaction has a cost, which is an integer defined as:
/// >
/// > max(serialized transaction size in bytes, 4000)
/// > Each transaction has a cost, which is an integer defined as...
///
/// [ZIP-401]: https://zips.z.cash/zip-0401
pub fn cost(&self) -> u64 {
Expand All @@ -384,11 +392,12 @@ impl VerifiedUnminedTx {
/// The computed _eviction weight_ of a verified unmined transaction as part
/// of the mempool set, as defined in [ZIP-317] and [ZIP-401].
///
/// Standard rule:
/// # Standard Rule
///
/// > Each transaction also has an eviction weight, which is cost +
/// > low_fee_penalty, where low_fee_penalty is 16000 if the transaction pays
/// > a fee less than the conventional fee, otherwise 0.
/// > Each transaction also has an *eviction weight*, which is *cost* + *low_fee_penalty*,
/// > where *low_fee_penalty* is 40000 if the transaction pays a fee less than the
/// > conventional fee, otherwise 0. The conventional fee is currently defined in
/// > [ZIP-317].
///
/// > zcashd and zebrad limit the size of the mempool as described in [ZIP-401].
/// > This specifies a low fee penalty that is added to the "eviction weight" if the transaction
Expand Down
12 changes: 6 additions & 6 deletions zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "ze

[dependencies]
blake2b_simd = "1.0.1"
bellman = "0.13.0"
bls12_381 = "0.7.0"
halo2 = { package = "halo2_proofs", version = "0.2.0" }
jubjub = "0.9.0"
bellman = "0.14.0"
bls12_381 = "0.8.0"
halo2 = { package = "halo2_proofs", version = "0.3.0" }
jubjub = "0.10.0"
rand = { version = "0.8.5", package = "rand" }
rayon = "1.7.0"

Expand All @@ -49,9 +49,9 @@ tower = { version = "0.4.13", features = ["timeout", "util", "buffer"] }
tracing = "0.1.37"
tracing-futures = "0.2.5"

orchard = "0.3.0"
orchard = "0.4.0"

zcash_proofs = { version = "0.10.0", features = ["local-prover", "multicore", "download-params"] }
zcash_proofs = { version = "0.11.0", features = ["local-prover", "multicore", "download-params"] }

tower-fallback = { path = "../tower-fallback/" }
tower-batch = { path = "../tower-batch/" }
Expand Down
2 changes: 0 additions & 2 deletions zebra-consensus/src/primitives/halo2/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ where
}

#[tokio::test(flavor = "multi_thread")]
// TODO: This test fails on nightly so it is temporally disabled. Enable when #6232 is resolved.
#[ignore]
async fn verify_generated_halo2_proofs() {
let _init_guard = zebra_test::init();

Expand Down
4 changes: 2 additions & 2 deletions zebra-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ insta = { version = "1.29.0", features = ["ron"] }
proptest = "1.1.0"
proptest-derive = "0.3.0"

halo2 = { package = "halo2_proofs", version = "0.2.0" }
jubjub = "0.9.0"
halo2 = { package = "halo2_proofs", version = "0.3.0" }
jubjub = "0.10.0"

tokio = { version = "1.27.0", features = ["full", "tracing", "test-util"] }

Expand Down