Skip to content
Open
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
8 changes: 7 additions & 1 deletion zebra-chain/src/block/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ proptest! {
SerializationError::Io(io_err) => {
prop_assert_eq![io_err.kind(), ErrorKind::UnexpectedEof];
}
_ => {
SerializationError::Parse(_)
| SerializationError::Utf8Error(_)
| SerializationError::TryFromSliceError(_)
| SerializationError::TryFromIntError(_)
| SerializationError::FromHexError(_)
| SerializationError::Amount { .. }
| SerializationError::BadTransactionBalance => {
prop_assert!(false,
"blocks larger than the maximum size should fail with an io::Error");
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/history_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl HistoryTree {
.cmp(&heartwood_height)
{
std::cmp::Ordering::Less => Ok(HistoryTree(None)),
_ => Ok(
std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => Ok(
NonEmptyHistoryTree::from_block(network, block, sapling_root, orchard_root)?.into(),
),
}
Expand Down
36 changes: 34 additions & 2 deletions zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,23 @@ impl Transaction {
joinsplit_data: Some(joinsplit_data),
..
} => Some(joinsplit_data.pub_key),
_ => None,
Transaction::V1 { .. }
| Transaction::V2 {
joinsplit_data: None,
..
}
| Transaction::V3 {
joinsplit_data: None,
..
}
| Transaction::V4 {
joinsplit_data: None,
..
}
| Transaction::V5 { .. } => None,

#[cfg(all(zcash_unstable = "nu7", feature = "tx_v6"))]
Transaction::V6 { .. } => None,
}
}

Expand All @@ -1435,7 +1451,23 @@ impl Transaction {
joinsplit_data: Some(joinsplit_data),
..
} => Some(joinsplit_data.sig),
_ => None,
Transaction::V1 { .. }
| Transaction::V2 {
joinsplit_data: None,
..
}
| Transaction::V3 {
joinsplit_data: None,
..
}
| Transaction::V4 {
joinsplit_data: None,
..
}
| Transaction::V5 { .. } => None,

#[cfg(all(zcash_unstable = "nu7", feature = "tx_v6"))]
Transaction::V6 { .. } => None,
}
}

Expand Down
8 changes: 7 additions & 1 deletion zebra-chain/src/transaction/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,12 @@ pub fn insert_fake_orchard_shielded_data(
.as_mut()
.expect("shielded data was just inserted")
}
_ => panic!("Fake V5 transaction is not V5"),
Transaction::V1 { .. }
| Transaction::V2 { .. }
| Transaction::V3 { .. }
| Transaction::V4 { .. } => panic!("Fake V5 transaction is not V5"),

#[cfg(all(zcash_unstable = "nu7", feature = "tx_v6"))]
Transaction::V6 { .. } => panic!("Fake V5 transaction is not V5"),
}
}
60 changes: 56 additions & 4 deletions zebra-consensus/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ impl VerifyBlockError {
match self {
VerifyBlockError::Block { source, .. } => source.is_duplicate_request(),
VerifyBlockError::Commit(commit_err) => commit_err.is_duplicate_request(),
_ => false,
VerifyBlockError::Depth { .. }
| VerifyBlockError::Equihash { .. }
| VerifyBlockError::Time(_)
| VerifyBlockError::ValidateProposal(_)
| VerifyBlockError::Transaction(_)
| VerifyBlockError::Subsidy(_)
| VerifyBlockError::StateService { .. } => false,
}
}

Expand All @@ -113,7 +119,13 @@ impl VerifyBlockError {
match self {
Block { source } => source.misbehavior_score(),
Equihash { .. } => 100,
_other => 0,
Depth { .. }
| Time(_)
| Commit(_)
| ValidateProposal(_)
| Transaction(_)
| Subsidy(_)
| StateService { .. } => 0,
}
}
}
Expand Down Expand Up @@ -189,7 +201,27 @@ where
return Err(BlockError::AlreadyInChain(hash, location).into())
}
zs::Response::KnownBlock(None) => {}
_ => unreachable!("wrong response to Request::KnownBlock"),
zs::Response::Committed(_)
| zs::Response::Invalidated(_)
| zs::Response::Reconsidered(_)
| zs::Response::Depth(_)
| zs::Response::Tip(_)
| zs::Response::BlockLocator(_)
| zs::Response::Transaction(_)
| zs::Response::AnyChainTransaction(_)
| zs::Response::UnspentBestChainUtxo(_)
| zs::Response::Block(_)
| zs::Response::BlockAndSize(_)
| zs::Response::BlockHeader { .. }
| zs::Response::Utxo(_)
| zs::Response::BlockHashes(_)
| zs::Response::BlockHeaders(_)
| zs::Response::ValidBestChainTipNullifiersAndAnchors
| zs::Response::BestChainNextMedianTimePast(_)
| zs::Response::BlockHash(_)
| zs::Response::ValidBlockProposal => {
unreachable!("wrong response to Request::KnownBlock")
}
}

tracing::trace!("performing block checks");
Expand Down Expand Up @@ -352,7 +384,27 @@ where
.map_err(VerifyBlockError::ValidateProposal)?
{
zs::Response::ValidBlockProposal => Ok(hash),
_ => unreachable!("wrong response for CheckBlockProposalValidity"),
zs::Response::Committed(_)
| zs::Response::Invalidated(_)
| zs::Response::Reconsidered(_)
| zs::Response::Depth(_)
| zs::Response::Tip(_)
| zs::Response::BlockLocator(_)
| zs::Response::Transaction(_)
| zs::Response::AnyChainTransaction(_)
| zs::Response::UnspentBestChainUtxo(_)
| zs::Response::Block(_)
| zs::Response::BlockAndSize(_)
| zs::Response::BlockHeader { .. }
| zs::Response::Utxo(_)
| zs::Response::BlockHashes(_)
| zs::Response::BlockHeaders(_)
| zs::Response::ValidBestChainTipNullifiersAndAnchors
| zs::Response::BestChainNextMedianTimePast(_)
| zs::Response::BlockHash(_)
| zs::Response::KnownBlock(_) => {
unreachable!("wrong response for CheckBlockProposalValidity")
}
};
}

Expand Down
70 changes: 66 additions & 4 deletions zebra-consensus/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,20 @@ impl VerifyCheckpointError {
// TODO: make this duplicate-incomplete
VerifyCheckpointError::NewerRequest { .. } => true,
VerifyCheckpointError::VerifyBlock(block_error) => block_error.is_duplicate_request(),
_ => false,
VerifyCheckpointError::Finished
| VerifyCheckpointError::TooHigh { .. }
| VerifyCheckpointError::CoinbaseHeight { .. }
| VerifyCheckpointError::BadMerkleRoot { .. }
| VerifyCheckpointError::DuplicateTransaction
| VerifyCheckpointError::Dropped
| VerifyCheckpointError::CommitCheckpointVerified(_)
| VerifyCheckpointError::Tip(_)
| VerifyCheckpointError::CheckpointList(_)
| VerifyCheckpointError::SubsidyError(_)
| VerifyCheckpointError::AmountError(_)
| VerifyCheckpointError::QueuedLimit
| VerifyCheckpointError::UnexpectedSideChain { .. }
| VerifyCheckpointError::ShuttingDown => false,
}
}

Expand All @@ -1051,7 +1064,18 @@ impl VerifyCheckpointError {
| VerifyCheckpointError::CoinbaseHeight { .. }
| VerifyCheckpointError::DuplicateTransaction
| VerifyCheckpointError::AmountError(_) => 100,
_other => 0,
VerifyCheckpointError::Finished
| VerifyCheckpointError::TooHigh { .. }
| VerifyCheckpointError::AlreadyVerified { .. }
| VerifyCheckpointError::NewerRequest { .. }
| VerifyCheckpointError::BadMerkleRoot { .. }
| VerifyCheckpointError::Dropped
| VerifyCheckpointError::CommitCheckpointVerified(_)
| VerifyCheckpointError::Tip(_)
| VerifyCheckpointError::CheckpointList(_)
| VerifyCheckpointError::QueuedLimit
| VerifyCheckpointError::UnexpectedSideChain { .. }
| VerifyCheckpointError::ShuttingDown => 0,
}
}
}
Expand Down Expand Up @@ -1139,7 +1163,27 @@ where
assert_eq!(committed_hash, hash, "state must commit correct hash");
Ok(hash)
}
_ => unreachable!("wrong response for CommitCheckpointVerifiedBlock"),
zs::Response::Invalidated(_)
| zs::Response::Reconsidered(_)
| zs::Response::Depth(_)
| zs::Response::Tip(_)
| zs::Response::BlockLocator(_)
| zs::Response::Transaction(_)
| zs::Response::AnyChainTransaction(_)
| zs::Response::UnspentBestChainUtxo(_)
| zs::Response::Block(_)
| zs::Response::BlockAndSize(_)
| zs::Response::BlockHeader { .. }
| zs::Response::Utxo(_)
| zs::Response::BlockHashes(_)
| zs::Response::BlockHeaders(_)
| zs::Response::ValidBestChainTipNullifiersAndAnchors
| zs::Response::BestChainNextMedianTimePast(_)
| zs::Response::BlockHash(_)
| zs::Response::KnownBlock(_)
| zs::Response::ValidBlockProposal => {
unreachable!("wrong response for CommitCheckpointVerifiedBlock")
}
}
});

Expand Down Expand Up @@ -1169,7 +1213,25 @@ where
.map_err(VerifyCheckpointError::Tip)?
{
zs::Response::Tip(tip) => tip,
_ => unreachable!("wrong response for Tip"),
zs::Response::Committed(_)
| zs::Response::Invalidated(_)
| zs::Response::Reconsidered(_)
| zs::Response::Depth(_)
| zs::Response::BlockLocator(_)
| zs::Response::Transaction(_)
| zs::Response::AnyChainTransaction(_)
| zs::Response::UnspentBestChainUtxo(_)
| zs::Response::Block(_)
| zs::Response::BlockAndSize(_)
| zs::Response::BlockHeader { .. }
| zs::Response::Utxo(_)
| zs::Response::BlockHashes(_)
| zs::Response::BlockHeaders(_)
| zs::Response::ValidBestChainTipNullifiersAndAnchors
| zs::Response::BestChainNextMedianTimePast(_)
| zs::Response::BlockHash(_)
| zs::Response::KnownBlock(_)
| zs::Response::ValidBlockProposal => unreachable!("wrong response for Tip"),
};
// Ignore errors since send() can fail only when the verifier
// is being dropped, and then it doesn't matter anymore.
Expand Down
26 changes: 24 additions & 2 deletions zebra-consensus/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,21 @@ impl TransactionError {
| WrongConsensusBranchId
| MissingConsensusBranchId => 100,

_other => 0,
NotCoinbase
| LockedUntilAfterBlockHeight(_)
| LockedUntilAfterBlockTime(_)
| MaximumExpiryHeight { .. }
| ExpiredTransaction { .. }
| UnsupportedByNetworkUpgrade(..)
| InternalDowncastError(_)
| DuplicateTransparentSpend(_)
| DuplicateSproutNullifier(_)
| DuplicateSaplingNullifier(_)
| DuplicateOrchardNullifier(_)
| TransparentInputNotFound
| ValidateContextError(_)
| ValidateMempoolLockTimeError(_)
| Zip317(_) => 0,
}
}
}
Expand Down Expand Up @@ -407,7 +421,15 @@ impl BlockError {
| InvalidDifficulty(_, _)
| TargetDifficultyLimit(_, _, _, _, _)
| DifficultyFilter(_, _, _, _) => 100,
_other => 0,
Transaction(_)
| NoTransactions
| BadMerkleRoot { .. }
| DuplicateTransaction
| AlreadyInChain(..)
| WrongTransactionConsensusBranchId
| TooManyTransparentSignatureOperations { .. }
| SummingMinerFees { .. }
| Other(_) => 0,
}
}
}
2 changes: 2 additions & 0 deletions zebra-consensus/src/primitives/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ pub enum Halo2Error {

impl From<halo2::plonk::Error> for Halo2Error {
fn from(err: halo2::plonk::Error) -> Halo2Error {
// halo2::plonk::Error is #[non_exhaustive]
#[allow(clippy::wildcard_enum_match_arm)]
match err {
halo2::plonk::Error::ConstraintSystemFailure => Halo2Error::ConstraintSystemFailure,
_ => Halo2Error::Other,
Expand Down
20 changes: 19 additions & 1 deletion zebra-consensus/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,25 @@ where
.unwrap()
{
zs::Response::Tip(tip) => tip,
_ => unreachable!("wrong response to Request::Tip"),
zs::Response::Committed(_)
| zs::Response::Invalidated(_)
| zs::Response::Reconsidered(_)
| zs::Response::Depth(_)
| zs::Response::BlockLocator(_)
| zs::Response::Transaction(_)
| zs::Response::AnyChainTransaction(_)
| zs::Response::UnspentBestChainUtxo(_)
| zs::Response::Block(_)
| zs::Response::BlockAndSize(_)
| zs::Response::BlockHeader { .. }
| zs::Response::Utxo(_)
| zs::Response::BlockHashes(_)
| zs::Response::BlockHeaders(_)
| zs::Response::ValidBestChainTipNullifiersAndAnchors
| zs::Response::BestChainNextMedianTimePast(_)
| zs::Response::BlockHash(_)
| zs::Response::KnownBlock(_)
| zs::Response::ValidBlockProposal => unreachable!("wrong response to Request::Tip"),
};
tracing::info!(
?tip,
Expand Down
Loading
Loading