-
Notifications
You must be signed in to change notification settings - Fork 653
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
Implement time travel for NEAR testing infrastructure #3661
Conversation
Upon basic inspection, the occurences of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the time_proxy
module? Also I don't think we need to have a Utc
submodule there
chain/chunks/src/lib.rs
Outdated
@@ -260,6 +260,7 @@ impl SealsManager { | |||
}; | |||
|
|||
let chosen = Self::get_random_part_ords(candidates); | |||
// `sent` is not accessed, so we don't use the time proxy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not used right now, but will be enabled after #3657 is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix this catch
The Alas, I caught a cold (this is a cold season after all) so this task will need to wait a few days. |
I'm back to coding. I'll pick up this task shortly. Please excuse the delay. |
I have the second sub-task compiling, and the last sub-task as a draft. Could you think of more tests utilizing time travel? If we spend effort implementing the feature that enables testing, we might as well add more testing. |
Without time travel, the test completes in 22 seconds. With time travel enabled, the test completes in 50 seconds half of the time, and gets stuck the other half of the time. The core simply does not work well with time changes. edit: it's possible that my proxy replacements are wrong or insufficient or incongruent in the core. edit: one proxy replacement was incorrect. |
4aec605
to
2f84d67
Compare
d0e2886
to
aeb233c
Compare
@bowenwang1996 @SkidanovAlex @chefsale @mfornet @pmnoxx please review, it's now passing the tests and checks. |
317b39a
to
9b19c1b
Compare
c6560db
to
6803ace
Compare
* Tests for another use case as well: not stopping time, but instead slowing it down by 70%, and making sure that on the same (relatively long) period of time 70% fewer blocks are produced.
4e2e671
to
208b1a9
Compare
Hi, @pczarn, the changes look good to me. |
Removes code that is not necessary for typical operation. Makes time travel affect all proxied locations when enabled. You may want to revert this commit in case you'd wish to hunt for incorrect proxifications using `scripts/find_time_travel_setting.py`.
done in the latest 2 commits @SkidanovAlex |
bed4a63
to
3cc40a6
Compare
@SkidanovAlex please allocate some time for a review |
print(f'block {h} {fr}->{to}') | ||
return True | ||
|
||
# consensus_config = {"consensus": {"min_num_peers": 0}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be removed?
The code looks good! @bowenwang1996 let's not merge until I figure out the issue with cluster.py. |
@@ -154,7 +154,7 @@ fn end_count_instructions() -> u64 { | |||
} | |||
|
|||
fn start_count_time() -> Consumed { | |||
Consumed::Instant(Instant::now()) | |||
Consumed::Instant(Instant::system_time()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this change? We do not need system time here, we need a way to count monotonic ticks between two moments.
Instant::now
does exactly what we need, i.e.
A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
While description of SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
is not behavior we're looking for here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you are misled by the fact that the change has no impact. The call still goes through to Instant::now
as before. Still, I wanted to introduce this name to bring attention to the fact that we decided not to go through a proxy.
A more descriptive name such as system_now
or unproxied_now
could be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olonho does my comment resolve your doubts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use monotonic clock when measuring system elapsed time in estimator.
This PR has been automatically marked as stale because it has not had recent activity in the 2 weeks. |
This PR has been automatically marked as stale because it has not had recent activity in the 2 weeks. |
@SkidanovAlex what's the status of this PR? |
@bowenwang1996 yes I did receive the payment for this PR. This PR is a good chance for me to learn since I can look into somebody's reimplementation. I can already see some things that could have been better in this PR. |
@pczarn I think that overall this is a good PR.However, in order to ship it safely a few steps would have been required. In the ideal scenario we could have done it like this:
|
Thanks for your contribution! If you see places for improvements, feel free to submit new PRs. |
Implements near/bounties#31
Document all occurences of
Utc::now
Please review and confirm the correctness of point one: