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

Refactor/mgr async tasks #145

Merged
merged 8 commits into from
Jul 29, 2024
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ libc = "0.2"
metrics = "0.23"
metrics-exporter-prometheus = "0.15"
moka = { version = "0.12", features = ["sync"] }
parking_lot = "0.12.1"
parking_lot = { version = "0.12.1", features = ["send_guard"] }
parking_lot_core = "0.9.9"
pin-project-lite = "0.2"
pkcs8 = "0.10"
Expand Down
16 changes: 8 additions & 8 deletions collator/src/collator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use crate::types::{
TopBlockDescription,
};
use crate::utils::async_queued_dispatcher::{
AsyncQueuedDispatcher, STANDARD_DISPATCHER_QUEUE_BUFFER_SIZE,
AsyncQueuedDispatcher, STANDARD_QUEUED_DISPATCHER_BUFFER_SIZE,
};
use crate::{method_to_async_task_closure, tracing_targets};
use crate::{method_to_queued_async_closure, tracing_targets};

mod build_block;
mod do_collate;
Expand Down Expand Up @@ -135,15 +135,15 @@ impl Collator for AsyncQueuedDispatcher<CollatorStdImpl> {
}

async fn equeue_update_mc_data_and_try_collate(&self, mc_data: Arc<McData>) -> Result<()> {
self.enqueue_task(method_to_async_task_closure!(
self.enqueue_task(method_to_queued_async_closure!(
update_mc_data_and_try_collate,
mc_data
))
.await
}

async fn equeue_try_collate(&self) -> Result<()> {
self.enqueue_task(method_to_async_task_closure!(try_collate,))
self.enqueue_task(method_to_queued_async_closure!(try_collate,))
.await
}

Expand All @@ -152,7 +152,7 @@ impl Collator for AsyncQueuedDispatcher<CollatorStdImpl> {
next_chain_time: u64,
top_shard_blocks_info: Vec<TopBlockDescription>,
) -> Result<()> {
self.enqueue_task(method_to_async_task_closure!(
self.enqueue_task(method_to_queued_async_closure!(
wait_state_and_do_collate,
next_chain_time,
top_shard_blocks_info
Expand Down Expand Up @@ -219,7 +219,7 @@ impl CollatorStdImpl {

// create dispatcher for own async tasks queue
let (dispatcher, receiver) =
AsyncQueuedDispatcher::new(STANDARD_DISPATCHER_QUEUE_BUFFER_SIZE);
AsyncQueuedDispatcher::new(STANDARD_QUEUED_DISPATCHER_BUFFER_SIZE);

let exec_manager = ExecutionManager::new(
shard_id,
Expand Down Expand Up @@ -268,7 +268,7 @@ impl CollatorStdImpl {
// equeue first initialization task
// sending to the receiver here cannot return Error because it is guaranteed not closed or dropped
dispatcher
.enqueue_task(method_to_async_task_closure!(
.enqueue_task(method_to_queued_async_closure!(
init,
prev_blocks_ids,
mc_data,
Expand Down Expand Up @@ -343,7 +343,7 @@ impl CollatorStdImpl {

// enqueue collation attempt of next block
self.dispatcher
.enqueue_task(method_to_async_task_closure!(try_collate,))
.enqueue_task(method_to_queued_async_closure!(try_collate,))
.await?;
tracing::info!(target: tracing_targets::COLLATOR,
"Collator (block_id={}): init: collation attempt enqueued", self.next_block_id_short,
Expand Down
20 changes: 20 additions & 0 deletions collator/src/collator/tests/do_collate_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ use crate::collator::CollatorStdImpl;
use crate::mempool::make_stub_anchor;
use crate::test_utils::try_init_test_tracing;

fn get_test_block_limits() -> BlockLimits {
BlockLimits {
bytes: everscale_types::models::BlockParamLimits {
underload: 1_000_000,
soft_limit: 2_000_000,
hard_limit: 3_000_000,
},
gas: everscale_types::models::BlockParamLimits {
underload: 1_000_000,
soft_limit: 2_000_000,
hard_limit: 3_000_000,
},
lt_delta: everscale_types::models::BlockParamLimits {
underload: 1_000_000,
soft_limit: 2_000_000,
hard_limit: 3_000_000,
},
}
}

#[test]
fn test_read_next_externals() {
try_init_test_tracing(tracing_subscriber::filter::LevelFilter::TRACE);
Expand Down
3 changes: 1 addition & 2 deletions collator/src/collator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ impl BlockLimitStats {

#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
pub enum BlockLimitsLevel {
Underload,
Soft,
Hard,
}
Expand Down Expand Up @@ -831,7 +830,7 @@ impl ShardAccountStuff {
);

anyhow::ensure!(
old_lib_descr.publishers.get(&self.account_addr)?.is_none(),
old_lib_descr.publishers.get(self.account_addr)?.is_none(),
"cannot add public library {key} of account {} because this public library's \
LibDescr record already lists this account as a publisher",
self.account_addr,
Expand Down
Loading
Loading