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 (c885de4) and [#7219 + #7218 + #7241 + #7226 + #7222 + #7238 + #7229] together #7243

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2812dba
Remove duplicate asserts
upbqdn Jul 15, 2023
5c061d9
Remove workarounds for inserting trees into NFS
upbqdn Jul 15, 2023
7868e71
Use correct height for constructing new chain
upbqdn Jul 15, 2023
60a287f
Don't push the 0th block into a chain
upbqdn Jul 15, 2023
0fd231c
Don't commit two blocks at the same height
upbqdn Jul 15, 2023
b4bf35c
Fix typo
teor2345 Jul 16, 2023
f6b8176
Add an async-error feature and an initial module structure
teor2345 Jul 11, 2023
ee78f36
Implement checking for panics in OS threads and async tasks
teor2345 Jul 12, 2023
74ce0d3
Implement waiting for panics in OS threads and async tasks
teor2345 Jul 13, 2023
a59b04e
Add a TODO to simplify some state request error handling
teor2345 Jul 13, 2023
35cdec5
Use the new panic-checking methods in zebra-state
teor2345 Jul 13, 2023
4b59bdd
Use new panic-checking methods in zebra-network
teor2345 Jul 17, 2023
9ddf377
fixup! Implement waiting for panics in OS threads and async tasks
teor2345 Jul 17, 2023
93ecfc5
Replace existing async code with generic panic-checking methods
teor2345 Jul 17, 2023
7c31404
Simplify trait to a single method
teor2345 Jul 17, 2023
22b0c5b
Move thread panic code into generic trait impls
teor2345 Jul 17, 2023
b54da8b
Generate chains with at least two blocks
upbqdn Jul 17, 2023
6c2eaa4
Merge branch 'fix-height-in-tests' of github.com:ZcashFoundation/zebr…
upbqdn Jul 17, 2023
389a2ba
build(deps): bump the cli group with 1 update
dependabot[bot] Jul 17, 2023
6910116
Simplify option handling
teor2345 Jul 17, 2023
0e65540
Fix comment
teor2345 Jul 17, 2023
b6a4f63
Add missing track_caller
teor2345 Jul 17, 2023
e6687b2
build(deps): bump insta from 1.30.0 to 1.31.0
dependabot[bot] Jul 17, 2023
6c3cf02
build(deps): bump the crypto group with 1 update
dependabot[bot] Jul 17, 2023
d4896be
Bumps sha2/secp256k1, updates deny.toml
arya2 Jul 17, 2023
deea124
removes unused import, updates method calls
arya2 Jul 17, 2023
a358127
Change dependabot.yml Actions schedule and fix groups
teor2345 Jul 18, 2023
2e248b8
Merge of #7219
mergify[bot] Jul 18, 2023
859acaf
Merge of #7218
mergify[bot] Jul 18, 2023
772aa04
Merge of #7241
mergify[bot] Jul 18, 2023
220277a
Merge of #7226
mergify[bot] Jul 18, 2023
3c3e64a
Merge of #7222
mergify[bot] Jul 18, 2023
4da828f
Merge of #7238
mergify[bot] Jul 18, 2023
e504245
Merge of #7229
mergify[bot] Jul 18, 2023
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: 0 additions & 3 deletions zebra-chain/src/block/height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ fn operator_tests() {
assert_eq!(None, Height(i32::MAX as u32) + 1);
assert_eq!(None, Height(u32::MAX) + 0);

assert_eq!(Some(Height(2)), Height(1) + 1);
assert_eq!(None, Height::MAX + 1);

// Adding negative numbers
assert_eq!(Some(Height(1)), Height(2) + -1);
assert_eq!(Some(Height(0)), Height(1) + -1);
Expand Down
5 changes: 4 additions & 1 deletion zebra-state/src/service/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ impl Strategy for PreparedChain {
}

let chain = chain.clone().expect("should be generated");
let count = (1..chain.1.len()).new_tree(runner)?;
// The generated chain should contain at least two blocks:
// 1. the zeroth genesis block, and
// 2. a first block.
let count = (2..chain.1.len()).new_tree(runner)?;
Ok(PreparedChainTree {
chain: chain.1,
count,
Expand Down
95 changes: 30 additions & 65 deletions zebra-state/src/service/non_finalized_state/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,26 +521,16 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding sprout tree");

// TODO: fix test code that incorrectly overwrites trees
#[cfg(not(test))]
{
assert_eq!(
self.sprout_trees_by_height.insert(height, tree.clone()),
None,
"incorrect overwrite of sprout tree: trees must be reverted then inserted",
);
assert_eq!(
self.sprout_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of sprout anchor: anchors must be reverted then inserted",
);
}

#[cfg(test)]
{
self.sprout_trees_by_height.insert(height, tree.clone());
self.sprout_anchors_by_height.insert(height, anchor);
}
assert_eq!(
self.sprout_trees_by_height.insert(height, tree.clone()),
None,
"incorrect overwrite of sprout tree: trees must be reverted then inserted",
);
assert_eq!(
self.sprout_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of sprout anchor: anchors must be reverted then inserted",
);

// Multiple inserts are expected here,
// because the anchors only change if a block has shielded transactions.
Expand Down Expand Up @@ -633,26 +623,16 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding sapling tree");

// TODO: fix test code that incorrectly overwrites trees
#[cfg(not(test))]
{
assert_eq!(
self.sapling_trees_by_height.insert(height, tree),
None,
"incorrect overwrite of sapling tree: trees must be reverted then inserted",
);
assert_eq!(
self.sapling_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of sapling anchor: anchors must be reverted then inserted",
);
}

#[cfg(test)]
{
self.sapling_trees_by_height.insert(height, tree);
self.sapling_anchors_by_height.insert(height, anchor);
}
assert_eq!(
self.sapling_trees_by_height.insert(height, tree),
None,
"incorrect overwrite of sapling tree: trees must be reverted then inserted",
);
assert_eq!(
self.sapling_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of sapling anchor: anchors must be reverted then inserted",
);

// Multiple inserts are expected here,
// because the anchors only change if a block has shielded transactions.
Expand Down Expand Up @@ -747,26 +727,16 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding orchard tree");

// TODO: fix test code that incorrectly overwrites trees
#[cfg(not(test))]
{
assert_eq!(
self.orchard_trees_by_height.insert(height, tree),
None,
"incorrect overwrite of orchard tree: trees must be reverted then inserted",
);
assert_eq!(
self.orchard_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of orchard anchor: anchors must be reverted then inserted",
);
}

#[cfg(test)]
{
self.orchard_trees_by_height.insert(height, tree);
self.orchard_anchors_by_height.insert(height, anchor);
}
assert_eq!(
self.orchard_trees_by_height.insert(height, tree),
None,
"incorrect overwrite of orchard tree: trees must be reverted then inserted",
);
assert_eq!(
self.orchard_anchors_by_height.insert(height, anchor),
None,
"incorrect overwrite of orchard anchor: anchors must be reverted then inserted",
);

// Multiple inserts are expected here,
// because the anchors only change if a block has shielded transactions.
Expand Down Expand Up @@ -850,16 +820,11 @@ impl Chain {
// Use the previously cached root which was calculated in parallel.
trace!(?height, "adding history tree");

// TODO: fix test code that incorrectly overwrites trees
#[cfg(not(test))]
assert_eq!(
self.history_trees_by_height.insert(height, tree),
None,
"incorrect overwrite of history tree: trees must be reverted then inserted",
);

#[cfg(test)]
self.history_trees_by_height.insert(height, tree);
}

/// Remove the History tree index at `height`.
Expand Down
12 changes: 6 additions & 6 deletions zebra-state/src/service/non_finalized_state/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn push_genesis_chain() -> Result<()> {

chain_values.insert(None, (None, only_chain.chain_value_pools.into()));

for block in chain.iter().take(count).cloned() {
for block in chain.iter().take(count).skip(1).cloned() {
let block =
ContextuallyVerifiedBlock::with_block_and_spent_utxos(
block,
Expand All @@ -72,7 +72,7 @@ fn push_genesis_chain() -> Result<()> {
chain_values.insert(block.height.into(), (block.chain_value_pool_change.into(), only_chain.chain_value_pools.into()));
}

prop_assert_eq!(only_chain.blocks.len(), count);
prop_assert_eq!(only_chain.blocks.len(), count - 1);
});

Ok(())
Expand Down Expand Up @@ -150,7 +150,7 @@ fn forked_equals_pushed_genesis() -> Result<()> {
empty_tree.clone(),
ValueBalance::zero(),
);
for block in chain.iter().take(fork_at_count).cloned() {
for block in chain.iter().take(fork_at_count).skip(1).cloned() {
let block = ContextuallyVerifiedBlock::with_block_and_spent_utxos(
block,
partial_chain.unspent_utxos(),
Expand All @@ -170,7 +170,7 @@ fn forked_equals_pushed_genesis() -> Result<()> {
empty_tree,
ValueBalance::zero(),
);
for block in chain.iter().cloned() {
for block in chain.iter().skip(1).cloned() {
let block =
ContextuallyVerifiedBlock::with_block_and_spent_utxos(block, full_chain.unspent_utxos())?;
full_chain = full_chain
Expand Down Expand Up @@ -460,7 +460,7 @@ fn rejection_restores_internal_state_genesis() -> Result<()> {
.unwrap_or(DEFAULT_PARTIAL_CHAIN_PROPTEST_CASES)),
|((chain, valid_count, network, mut bad_block) in (PreparedChain::default(), any::<bool>(), any::<bool>())
.prop_flat_map(|((chain, valid_count, network, _history_tree), is_nu5, is_v5)| {
let next_height = chain[valid_count - 1].height;
let next_height = chain[valid_count].height;
(
Just(chain),
Just(valid_count),
Expand All @@ -486,7 +486,7 @@ fn rejection_restores_internal_state_genesis() -> Result<()> {
// use `valid_count` as the number of valid blocks before an invalid block
let valid_tip_height = chain[valid_count - 1].height;
let valid_tip_hash = chain[valid_count - 1].hash;
let mut chain = chain.iter().take(valid_count).cloned();
let mut chain = chain.iter().take(valid_count).skip(1).cloned();

prop_assert!(state.eq_internal_state(&state));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ fn construct_many() -> Result<()> {

let mut block: Arc<Block> =
zebra_test::vectors::BLOCK_MAINNET_434873_BYTES.zcash_deserialize_into()?;
let initial_height = block
.coinbase_height()
.expect("Block 434873 should have its height in its coinbase tx.");
let mut blocks = vec![];

while blocks.len() < 100 {
Expand All @@ -75,7 +78,7 @@ fn construct_many() -> Result<()> {

let mut chain = Chain::new(
Network::Mainnet,
Height(block.coinbase_height().unwrap().0 - 1),
(initial_height - 1).expect("Initial height should be at least 1."),
Default::default(),
Default::default(),
Default::default(),
Expand Down