Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into scan-db-tx-row
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Dec 6, 2023
2 parents 17ef519 + 358e52b commit 54fdc8a
Show file tree
Hide file tree
Showing 18 changed files with 499 additions and 174 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/ci-build-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
strategy:
# avoid rate-limit errors by only launching a few of these jobs at a time,
# but still finish in a similar time to the longest tests
max-parallel: 3
max-parallel: 4
fail-fast: true
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}

Expand All @@ -134,21 +134,16 @@ jobs:
#
# Some Zebra crates do not have any features, and most don't have any default features.
# Some targets activate features, but we still need to be able to build without them.
- name: Build ${{ matrix.crate }} crate with no default features
- name: Build ${{ matrix.crate }} crate with default features
run: |
cargo clippy --package ${{ matrix.crate }} --no-default-features -- -D warnings
cargo build --package ${{ matrix.crate }} --no-default-features
cargo clippy --package ${{ matrix.crate }} -- -D warnings
cargo build --package ${{ matrix.crate }}
- name: Build ${{ matrix.crate }} crate with no default features and all targets
run: |
cargo clippy --package ${{ matrix.crate }} --no-default-features --all-targets -- -D warnings
cargo build --package ${{ matrix.crate }} --no-default-features --all-targets
- name: Build ${{ matrix.crate }} crate with default features
run: |
cargo clippy --package ${{ matrix.crate }} -- -D warnings
cargo build --package ${{ matrix.crate }}
- name: Build ${{ matrix.crate }} crate with default features and all targets
run: |
cargo clippy --package ${{ matrix.crate }} --all-targets -- -D warnings
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5798,6 +5798,7 @@ name = "zebra-scan"
version = "0.1.0-alpha.0"
dependencies = [
"bls12_381",
"chrono",
"color-eyre",
"ff",
"group",
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl Error {
/// -MAX_MONEY..=MAX_MONEY,
/// );
/// ```
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)]
pub struct NegativeAllowed;

impl Constraint for NegativeAllowed {
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/block/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use proptest_derive::Arbitrary;
/// Note: Zebra displays transaction and block hashes in big-endian byte-order,
/// following the u256 convention set by Bitcoin and zcashd.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary, Default))]
pub struct Hash(pub [u8; 32]);

impl Hash {
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/block/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use proptest_derive::Arbitrary;
///
/// [ZIP-244]: https://zips.z.cash/zip-0244
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary, Default))]
pub struct Root(pub [u8; 32]);

impl fmt::Debug for Root {
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ where

/// Wrapper to override `Debug`, redirecting it to hex-encode the type.
/// The type must implement `AsRef<[u8]>`.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Default)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[serde(transparent)]
pub struct HexDebug<T: AsRef<[u8]>>(pub T);
Expand Down
4 changes: 3 additions & 1 deletion zebra-chain/src/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub mod shielded_data;
pub mod spend;
pub mod tree;

pub use commitment::{CommitmentRandomness, NoteCommitment, ValueCommitment};
pub use commitment::{
CommitmentRandomness, NotSmallOrderValueCommitment, NoteCommitment, ValueCommitment,
};
pub use keys::Diversifier;
pub use note::{EncryptedNote, Note, Nullifier, WrappedNoteKey};
pub use output::{Output, OutputInTransactionV4, OutputPrefixInTransactionV5};
Expand Down
2 changes: 2 additions & 0 deletions zebra-chain/src/sapling/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ impl NoteCommitment {
///
/// <https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit>
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Default))]
pub struct ValueCommitment(#[serde(with = "serde_helpers::AffinePoint")] jubjub::AffinePoint);

impl<'a> std::ops::Add<&'a ValueCommitment> for ValueCommitment {
Expand Down Expand Up @@ -302,6 +303,7 @@ lazy_static! {
/// <https://zips.z.cash/protocol/protocol.pdf#spenddesc>
/// <https://zips.z.cash/protocol/protocol.pdf#outputdesc>
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Default))]
pub struct NotSmallOrderValueCommitment(ValueCommitment);

impl TryFrom<ValueCommitment> for NotSmallOrderValueCommitment {
Expand Down
12 changes: 12 additions & 0 deletions zebra-chain/src/sapling/note/ciphertexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}
#[derive(Deserialize, Serialize)]
pub struct EncryptedNote(#[serde(with = "BigArray")] pub(crate) [u8; 580]);

impl From<[u8; 580]> for EncryptedNote {
fn from(byte_array: [u8; 580]) -> Self {
Self(byte_array)
}
}

impl fmt::Debug for EncryptedNote {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("EncryptedNote")
Expand Down Expand Up @@ -59,6 +65,12 @@ impl ZcashDeserialize for EncryptedNote {
#[derive(Deserialize, Serialize)]
pub struct WrappedNoteKey(#[serde(with = "BigArray")] pub(crate) [u8; 80]);

impl From<[u8; 80]> for WrappedNoteKey {
fn from(byte_array: [u8; 80]) -> Self {
Self(byte_array)
}
}

impl fmt::Debug for WrappedNoteKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("WrappedNoteKey")
Expand Down
1 change: 1 addition & 0 deletions zebra-chain/src/work/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mod tests;
///
/// [section 7.7.4]: https://zips.z.cash/protocol/protocol.pdf#nbits
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Default))]
pub struct CompactDifficulty(pub(crate) u32);

/// An invalid CompactDifficulty value, for testing.
Expand Down
7 changes: 7 additions & 0 deletions zebra-chain/src/work/equihash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ impl Clone for Solution {

impl Eq for Solution {}

#[cfg(any(test, feature = "proptest-impl"))]
impl Default for Solution {
fn default() -> Self {
Self([0; SOLUTION_SIZE])
}
}

impl ZcashSerialize for Solution {
fn zcash_serialize<W: io::Write>(&self, writer: W) -> Result<(), io::Error> {
zcash_serialize_bytes(&self.0.to_vec(), writer)
Expand Down
2 changes: 2 additions & 0 deletions zebra-scan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ zcash_primitives = "0.13.0-rc.1"
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.31" }
zebra-state = { path = "../zebra-state", version = "1.0.0-beta.31", features = ["shielded-scan"] }

chrono = { version = "0.4.31", default-features = false, features = ["clock", "std", "serde"] }

[dev-dependencies]

bls12_381 = "0.8.0"
Expand Down
Loading

0 comments on commit 54fdc8a

Please sign in to comment.