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

feat: Implement measuring of network round-trip time for sending state witness and receiving the ack #10824

Merged
merged 27 commits into from
Mar 20, 2024

Conversation

tayfunelmas
Copy link
Contributor

@tayfunelmas tayfunelmas commented Mar 18, 2024

The goal here is to measure the network time spent (see issue #10790)

1 when sending state-witness from chunk producers to validators and
2 when sending the endorsement message from chunk validators to block producers.

But, for (2), we send an ack message (ChunkStateWitness) from the validator back to the chunk producer. This is not fully accurate but should give us some picture of the duration. We do not change the state-witness time to record the sent-time. Instead we keep the sent-time in the chunk producer (for which we add ChunkStateWitnessTracker to the Client) along with the hash of the chunk for which witness is created. Then upon receiving the ack message, we calculate the duration and store it in a metric in the chunk producer.

Most of the logic is in state_witness_tracker.rs. Note that this implementation is for experimenting with network time estimates for now and, since we are not changing the witness messages, having ack messages is optional and we may remove it later when we have a stable implementation. We have not added a feature flag for it (though guarded by statelessnet_protocol) and may want to add a compile flag later before releasing statelessnet_protocol in mainnet.

Note that we make the assumption that the messages are directly sent between nodes (no intermediary hop node).

@tayfunelmas tayfunelmas requested a review from a team as a code owner March 18, 2024 18:59
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.

overall LGTM, added a bunch of comments

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.

LGTM!

chain/network/src/network_protocol/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@akhi3030 akhi3030 left a comment

Choose a reason for hiding this comment

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

LGTM! Just some minor nits.

chain/client/src/metrics.rs Outdated Show resolved Hide resolved
chain/client/src/stateless_validation/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

Good stuff, just a few nits and comments from me!

@walnut-the-cat
Copy link
Contributor

How will 'send_state_witness_ack' work if we decide to implement multi-hop strategy? It will be great for us to outline assumptions we are making with the approach

@tayfunelmas tayfunelmas added this pull request to the merge queue Mar 20, 2024
@tayfunelmas tayfunelmas removed this pull request from the merge queue due to a manual request Mar 20, 2024
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 92.52874% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 71.42%. Comparing base (21fba5b) to head (5612565).

Files Patch % Lines
.../src/stateless_validation/state_witness_tracker.rs 95.41% 2 Missing and 3 partials ⚠️
chain/client/src/test_utils/setup.rs 0.00% 3 Missing ⚠️
chain/network/src/network_protocol/mod.rs 0.00% 2 Missing ⚠️
chain/network/src/client.rs 0.00% 0 Missing and 1 partial ⚠️
core/primitives/src/stateless_validation.rs 75.00% 0 Missing and 1 partial ⚠️
tools/chainsync-loadtest/src/network.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10824      +/-   ##
==========================================
- Coverage   71.43%   71.42%   -0.01%     
==========================================
  Files         763      764       +1     
  Lines      153722   153894     +172     
  Branches   153722   153894     +172     
==========================================
+ Hits       109807   109917     +110     
- Misses      38919    38974      +55     
- Partials     4996     5003       +7     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.41% <0.00%> (-0.01%) ⬇️
integration-tests 36.83% <62.64%> (+0.03%) ⬆️
linux 70.05% <66.66%> (-0.01%) ⬇️
linux-nightly 70.93% <92.52%> (-0.02%) ⬇️
macos 54.40% <66.66%> (-0.28%) ⬇️
pytests 1.64% <0.00%> (-0.01%) ⬇️
sanity-checks 1.42% <0.00%> (-0.01%) ⬇️
unittests 67.12% <72.41%> (-0.04%) ⬇️
upgradability 0.29% <0.00%> (-0.01%) ⬇️

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.

@tayfunelmas tayfunelmas added this pull request to the merge queue Mar 20, 2024
Merged via the queue into near:master with commit f2f6ed0 Mar 20, 2024
30 of 31 checks passed
@tayfunelmas tayfunelmas deleted the witness-roundtrip-metric branch March 20, 2024 21:51
@walnut-the-cat walnut-the-cat added the A-stateless-validation Area: stateless validation label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stateless-validation Area: stateless validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants