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

test: add extra stats to cross_shard_tx #3057

Merged
merged 8 commits into from
Aug 11, 2020

Conversation

pmnoxx
Copy link
Contributor

@pmnoxx pmnoxx commented Jul 29, 2020

The usefulness and flakiness of cross_shard_tx depends heavily on the block production time.

This change adds printing block stats every minute, we will print the following:

  • ratio of number of blocks to longest chain
  • maximum divergence between recently produced blocks

In addition we will fail cross_shard_tx test if the ratio is too high or to low, depending on test parameters.

#3014

@gitpod-io
Copy link

gitpod-io bot commented Jul 29, 2020

@pmnoxx pmnoxx requested a review from SkidanovAlex July 29, 2020 22:49
@pmnoxx pmnoxx force-pushed the piotr-cross-shard-tx branch 2 times, most recently from 9c90f67 to d9bd7e6 Compare July 29, 2020 22:53
@codecov
Copy link

codecov bot commented Jul 30, 2020

Codecov Report

Merging #3057 into master will decrease coverage by 0.13%.
The diff coverage is 27.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3057      +/-   ##
==========================================
- Coverage   87.39%   87.26%   -0.14%     
==========================================
  Files         212      212              
  Lines       41322    41377      +55     
==========================================
- Hits        36115    36108       -7     
- Misses       5207     5269      +62     
Impacted Files Coverage Δ
chain/client/src/test_utils.rs 81.32% <19.64%> (-10.20%) ⬇️
chain/client/tests/bug_repros.rs 94.70% <100.00%> (ø)
chain/client/tests/chunks_management.rs 97.42% <100.00%> (ø)
chain/client/tests/cross_shard_tx.rs 93.02% <100.00%> (ø)
chain/client/tests/process_blocks.rs 90.75% <100.00%> (+0.53%) ⬆️
chain/jsonrpc/src/lib.rs 61.81% <0.00%> (-3.64%) ⬇️
chain/client/src/sync.rs 86.21% <0.00%> (-0.46%) ⬇️
chain/chain/src/store.rs 86.27% <0.00%> (-0.06%) ⬇️
chain/chain/src/validate.rs 90.32% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ddefbf...1aefeca. Read the comment docs.

@pmnoxx pmnoxx marked this pull request as ready for review July 30, 2020 02:49
@pmnoxx pmnoxx requested a review from bowenwang1996 as a code owner July 30, 2020 02:49
impl BlockStats {
fn new() -> BlockStats {
BlockStats {
hash2height: HashMap::new(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename it to hash2depth or hash2length (and then consistently use length or depth throughout to refer to the number of blocks on the chain), to avoid the confusion with the actual block heights.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was marked as resolved, but the name is still hash2height. Not sure if there's a change that wasn't pushed yet?

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One small issue I see is that orphans are not handled in add_block. I am not sure whether that is a possibility.

@pmnoxx
Copy link
Contributor Author

pmnoxx commented Jul 31, 2020

Looks good to me. One small issue I see is that orphans are not handled in add_block. I am not sure whether that is a possibility.

I was thinking about adding code to handle this case. I would add a panic in case we see a situation like this.

However I decided to keep the code simple. In case there is an orphan, we will see a panic due to unwrap. I could replace .unwrap() with expect("....") if you think this code will be more clear.

@bowenwang1996
Copy link
Collaborator

Looks good to me. One small issue I see is that orphans are not handled in add_block. I am not sure whether that is a possibility.

I was thinking about adding code to handle this case. I would add a panic in case we see a situation like this.

However I decided to keep the code simple. In case there is an orphan, we will see a panic due to unwrap. I could replace .unwrap() with expect("....") if you think this code will be more clear.

Are you sure? I only see this

        let prev_depth = self.hash2depth.get(block.header().prev_hash()).map(|v| *v).unwrap_or(0);

which doesn't panic.

@pmnoxx pmnoxx force-pushed the piotr-cross-shard-tx branch from 23ec71f to cb38ce3 Compare August 6, 2020 00:21
@SkidanovAlex
Copy link
Collaborator

@bowenwang1996 we never have the same block producer twice in a row, and thus a block cannot be created unless its parent was sent over the network. Given the code you are commenting is the callback that is triggered for each network message, it is impossible for a block to be handled before it's parent was handled.

@pmnoxx pmnoxx closed this Aug 6, 2020
@pmnoxx pmnoxx reopened this Aug 6, 2020
@gitpod-io
Copy link

gitpod-io bot commented Aug 6, 2020

@pmnoxx pmnoxx force-pushed the piotr-cross-shard-tx branch 2 times, most recently from d3866f4 to 4408395 Compare August 6, 2020 22:15
@pmnoxx pmnoxx force-pushed the piotr-cross-shard-tx branch from 9868e81 to 1aefeca Compare August 11, 2020 08:46
@nearprotocol-bulldozer nearprotocol-bulldozer bot merged commit 58a0370 into master Aug 11, 2020
@nearprotocol-bulldozer nearprotocol-bulldozer bot deleted the piotr-cross-shard-tx branch August 11, 2020 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants