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_loop: add a malicious chunk producer test #12795

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Jan 24, 2025

No description provided.

@nagisa nagisa requested a review from pugachAG January 24, 2025 13:29
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.

Project coverage is 70.44%. Comparing base (5f68d8c) to head (0f522af).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
chain/client/src/client_actor.rs 75.00% 0 Missing and 1 partial ⚠️
core/async/src/test_loop.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #12795       +/-   ##
===========================================
+ Coverage    1.70%   70.44%   +68.73%     
===========================================
  Files         676      854      +178     
  Lines      121191   174588    +53397     
  Branches   121191   174588    +53397     
===========================================
+ Hits         2065   122986   +120921     
+ Misses     119010    46362    -72648     
- Partials      116     5240     +5124     
Flag Coverage Δ
backward-compatibility 0.35% <0.00%> (?)
db-migration 0.35% <0.00%> (?)
genesis-check 1.40% <0.00%> (-0.01%) ⬇️
linux 70.00% <96.55%> (+68.30%) ⬆️
linux-nightly 70.07% <93.93%> (?)
pytests 1.71% <0.00%> (+0.01%) ⬆️
sanity-checks 1.52% <0.00%> (-0.01%) ⬇️
unittests 70.26% <93.93%> (?)
upgradability 0.35% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pugachAG
Copy link
Contributor

pugachAG commented Feb 5, 2025

overall looks good to me!

@nagisa nagisa force-pushed the add-chunk-producer-test branch 2 times, most recently from 72e3a1e to 5fa6826 Compare February 5, 2025 18:08
@nagisa nagisa marked this pull request as ready for review February 5, 2025 18:08
@nagisa nagisa requested a review from a team as a code owner February 5, 2025 18:08
@nagisa
Copy link
Collaborator Author

nagisa commented Feb 5, 2025

Alright, I have rebased this. I was meaning to add additional asserts around e.g. heights that all nodes reach, but it seems like that's already done as part of run_until.

@nagisa nagisa force-pushed the add-chunk-producer-test branch from 5fa6826 to e1948bd Compare February 5, 2025 18:11
Copy link
Contributor

@pugachAG pugachAG left a comment

Choose a reason for hiding this comment

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

added minor suggestion, otherwise LGMT, thanks!

let chunk_producer = chunk_producer.clone();
let sender = account.clone();
let receiver = accounts[0].clone();
test_loop.send_adhoc_event(format!("transaction"), move |data| {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you don't need format! here

// For a good measure insert some invalid transactions that may be invalid in other ways than
// them having been expired.
let data_clone = node_datas.clone();
test_loop.send_adhoc_event(format!("produce chunks without validity checks"), move |_| {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: another format!

let actual = clients.query_balance(account);
assert_eq!(actual, 1000000 * ONE_NEAR, "no transfers should have happened");
}
test_loop_env.shutdown_and_drain_remaining_events(Duration::seconds(20));
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice to also somehow check that those transactions were actually included in some chunk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used prometheus metrics for this.

I went ahead with adding a new metric for the number of transactions
that make their way to `fn apply`. That's because the transactions that
fail validation don't otherwise end up represended in
`TRANSACTION_PROCESSED_TOTAL` anymore.
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.

2 participants