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

[feature] #2100: Add query to find all accounts with asset #2197

Merged

Conversation

Arjentix
Copy link
Contributor

Description of the Change

  • Added FindAccountsWithAsset query
  • Added test for it
  • Fixed bug when block events (including Committed event) were sent before actual block applying to WSV
  • Cause of this bugfix some of previously flaky tests are no longer such. Tested with cargo flaky running every test for 100 times for about 4 hours
  • Smartcontract test is enabled back as it seems not being flaky anymore. But still takes about 50 secs to complete on my machine

Results of running cargo flaky (edited for readability):

====== FOUND 4 FAILING TESTS ======
- test: two_networks stdout
failures: 1/100 (1%)

- test: integration::unregister_peer::unstable_network_stable_after_add_and_after_remove_peer stdout
failures: 2/100 (2%)

- test: config::tests::parse_example_json stdout
failures: 100/100 (100%)

- test: ui stdout
failures: 600/100 (600%)

The 3'rd case isn't a real problem. This test just depends on a folder it runs from, we should be able to fix it probably.
The 4'th case is a compilation tests (as @mversic suggested). Not sure what does it means here.

Issue

Benefits

  • New query
  • Less number of flaky tests

Possible Drawbacks

I've enabled mint_nft_for_every_user_every_1_sec test back. I haven't run cargo flaky with it but I've run it mannually (bash script) for about 30 times and it seems to work fine. The only problem is a long execution time (~50 sec on my M1 Mac), so probably I need to ignore this test again.

Usage Examples or Tests

cargo test --package iroha_client --test mod -- integration::queries::account::find_accounts_with_asset --exact --nocapture

@Arjentix Arjentix added Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST labels May 11, 2022
@Arjentix Arjentix force-pushed the find_all_accounts_with_asset branch from 4e2055c to d3a4f36 Compare May 11, 2022 20:33
@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #2197 (d3a4f36) into iroha2-dev (10ac54c) will decrease coverage by 71.32%.
The diff coverage is 5.40%.

❗ Current head d3a4f36 differs from pull request most recent head a574e4f. Consider uploading reports for the commit a574e4f to get more accurate results

@@              Coverage Diff               @@
##           iroha2-dev   #2197       +/-   ##
==============================================
- Coverage       76.57%   5.25%   -71.33%     
==============================================
  Files             185     141       -44     
  Lines           26704   21653     -5051     
==============================================
- Hits            20449    1137    -19312     
- Misses           6255   20516    +14261     
Impacted Files Coverage Δ
core/src/smartcontracts/isi/account.rs 0.00% <0.00%> (-44.04%) ⬇️
core/src/smartcontracts/isi/query.rs 0.00% <0.00%> (-83.10%) ⬇️
core/src/sumeragi/fault.rs 0.00% <0.00%> (-82.20%) ⬇️
data_model/src/query.rs 0.00% <0.00%> (-31.31%) ⬇️
...issions_validators/src/private_blockchain/query.rs 0.00% <ø> (-4.40%) ⬇️
tools/parity_scale_decoder/src/generate_map.rs 0.00% <0.00%> (-99.41%) ⬇️
client/build.rs 97.50% <100.00%> (+44.16%) ⬆️
core/src/lib.rs 0.00% <0.00%> (-100.00%) ⬇️
cli/src/config.rs 0.00% <0.00%> (-100.00%) ⬇️
logger/src/lib.rs 0.00% <0.00%> (-100.00%) ⬇️
... and 180 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 10ac54c...a574e4f. Read the comment docs.

Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
@Arjentix Arjentix force-pushed the find_all_accounts_with_asset branch from 12dc80d to e4a2844 Compare May 12, 2022 19:20
@@ -27,32 +27,28 @@ fn main() {
.expect("Failed to run `rustfmt` on smartcontract");
assert!(fmt.success(), "Can't format smartcontract");

let instrumenting_coverage = if let Ok(flags) = env::var("RUSTFLAGS") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note from here:

Note that since Rust 1.55, RUSTFLAGS is removed from the environment; scripts should use CARGO_ENCODED_RUSTFLAGS instead.

mversic
mversic previously approved these changes May 13, 2022
core/src/smartcontracts/isi/query.rs Show resolved Hide resolved
if let Err(error) = self.wsv.apply(block.clone()).await {
warn!(?error, %block_hash, "Failed to apply block on WSV");
}

for event in Vec::<Event>::from(&block) {
trace!(?event);
drop(self.events_sender.send(event));
Copy link
Contributor

Choose a reason for hiding this comment

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

off topic comment. I've wondered before about this drop. No big deal

@mversic mversic self-assigned this May 13, 2022
@@ -746,14 +746,15 @@ impl<G: GenesisNetworkTrait, K: KuraTrait, W: WorldTrait, F: FaultInjection>
let block = block.commit();
let block_hash = block.hash();

if let Err(error) = self.wsv.apply(block.clone()).await {
warn!(?error, %block_hash, "Failed to apply block on WSV");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

so this change fixed flakiness?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@appetrosyan appetrosyan self-assigned this May 13, 2022
appetrosyan
appetrosyan previously approved these changes May 13, 2022
@Arjentix Arjentix dismissed stale reviews from appetrosyan and mversic via f1dc227 May 13, 2022 07:41
appetrosyan
appetrosyan previously approved these changes May 13, 2022
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
@appetrosyan appetrosyan merged commit 698d19d into hyperledger:iroha2-dev May 13, 2022
@Arjentix Arjentix deleted the find_all_accounts_with_asset branch May 13, 2022 08:07
appetrosyan pushed a commit to appetrosyan/iroha that referenced this pull request May 13, 2022
appetrosyan pushed a commit to appetrosyan/iroha that referenced this pull request May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants