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

Increase priority of timer over txpool event #2345

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- [2350](https://github.com/FuelLabs/fuel-core/pull/2350): Added a new CLI flag `graphql-number-of-threads` to limit the number of threads used by the GraphQL service. The default value is `2`, `0` enables the old behavior.

### Changed
### Fixed
- [2345](https://github.com/FuelLabs/fuel-core/pull/2345): In PoA increase priority of block creation timer trigger compare to txpool event management

### Changed
- [2334](https://github.com/FuelLabs/fuel-core/pull/2334): Prepare the GraphQL service for the switching to `async` methods.
- [2350](https://github.com/FuelLabs/fuel-core/pull/2350): Limited the number of threads used by the GraphQL service.

Expand Down
8 changes: 4 additions & 4 deletions crates/services/consensus_module/poa/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,6 @@ where
should_continue = false;
}
}
_ = self.new_txs_watcher.changed() => {
self.on_txpool_event().await.context("While processing txpool event")?;
should_continue = true;
}
_ = next_block_production => {
match self.on_timer().await.context("While processing timer event") {
Ok(()) => should_continue = true,
Expand All @@ -587,6 +583,10 @@ where
}
};
}
_ = self.new_txs_watcher.changed() => {
self.on_txpool_event().await.context("While processing txpool event")?;
should_continue = true;
}
}

Ok(should_continue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,32 @@ async fn interval_trigger_produces_blocks_in_the_future_when_time_rewinds() {
// similarly to how it works when time is lagging.
assert_eq!(second_block_time, start_time + block_time.as_secs() * 2);
}

#[tokio::test]
async fn interval_trigger_even_if_queued_tx_events() {
let block_time = Duration::from_secs(2);
let mut ctx = DefaultContext::new(Config {
trigger: Trigger::Interval { block_time },
signer: SignMode::Key(test_signing_key()),
metrics: false,
..Default::default()
})
.await;
let block_creation_notifier = Arc::new(Notify::new());
tokio::task::spawn({
let notifier = ctx.new_txs_notifier.clone();
async move {
loop {
time::sleep(Duration::from_nanos(10)).await;
notifier.send_replace(());
}
}
});
let block_creation_waiter = block_creation_notifier.clone();
tokio::task::spawn(async move {
ctx.block_import.recv().await.unwrap();
dbg!("First block produced");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Maybe clean up dbg statement

block_creation_notifier.notify_waiters();
});
block_creation_waiter.notified().await;
}
Loading