-
Notifications
You must be signed in to change notification settings - Fork 56
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
Orchestrator Async runtime improvements #274
Conversation
async runtime in |
|
I changed |
The last commit is for |
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.
Left some feedback. In particular I think I might disagree with the auditor's suggestion for the main loops, so perhaps we should discuss that.
(Ok(_latest_eth_block), Ok(ChainStatus::Syncing)) => { | ||
warn!("Cosmos node syncing, Eth oracle paused"); | ||
delay_for(DELAY).await; | ||
continue; |
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.
In the old version of this loop, we could fail faster (in this case only waiting DELAY
instead of ETH_ORACLE_LOOP_SPEED
) and try from the beginning of the loop again. In the tokio join!
model we'll always wait the full ETH_ORACLE_LOOP_SPEED
before starting again. I know that the task joining model was suggested by the auditor, and it is cleaner, but probably performs worse in cases where we'd rather restart the loop. Based on the comments at the bottom around the elapsed time calculation, we might care more about performance than wall clock consistency.
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.
@cbrit, the problem here isn't sleep
, rather it's join
. With join
, we have to wait the full ETH_ORACLE_LOOP_SPEED
before starting again. However, the previous code had continue
.
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.
@hannydevelop I know. I am suggesting that interval
might be a better solution than join
because it allows us to continue
the loop while still making sure the loop only runs every ETH_ORACLE_LOOP_SPEED
seconds if the match
is a successful case.
The auditor said
using Instant::now() leads to non-exact timeouts and loop_speed because the checks are always if the elapsed time is greater or lesser than a fixed Duration"
but this is solved by interval
.
As far as performance, I am not sure how it differs from join
, or how much it really matters.
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.
In my opinion, I'll rather use timeout
and sleep
or return back to using Instant::now
. Let's discuss this on Monday, I can try to contact the auditor for the logic behind using join
in main_loop
current_eth_valset_nonce = get_valset_nonce(gravity_address, *MINER_ADDRESS, &web30) | ||
.await | ||
.expect("Failed to get current eth valset"); | ||
tokio::time::sleep(std::time::Duration::from_secs(4)).await; |
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.
Same use
statement stuff around delay_for
and Duration
in happy_path
and happy_path_v2
as in the earlier files in the changeset, just noting it here once rather than highlighting each instance.
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.
This commit: fc227ac fixes this, thank you.
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.
Ah, what I meant was rather that we can include use std::time::Duration
and then when we call sleep, just refer to it like tokio::time::sleep(Duration::from_secs(...))
, since there is no ambiguity to require fully qualifying it inline.
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.
Left some feedback on the updates.
current_eth_valset_nonce = get_valset_nonce(gravity_address, *MINER_ADDRESS, &web30) | ||
.await | ||
.expect("Failed to get current eth valset"); | ||
tokio::time::sleep(std::time::Duration::from_secs(4)).await; |
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.
Ah, what I meant was rather that we can include use std::time::Duration
and then when we call sleep, just refer to it like tokio::time::sleep(Duration::from_secs(...))
, since there is no ambiguity to require fully qualifying it inline.
Merge branch 'main' into ukpai/async_improvement
oops, last commit message is wrong: fixed conflicting files, ran |
No description provided.