diff --git a/linera-chain/src/chain.rs b/linera-chain/src/chain.rs index fc457a993a7..802e0c34701 100644 --- a/linera-chain/src/chain.rs +++ b/linera-chain/src/chain.rs @@ -30,7 +30,7 @@ use linera_execution::{ use linera_views::{ context::Context, log_view::LogView, - queue_view::QueueView, + bucket_queue_view::BucketQueueView, reentrant_collection_view::ReentrantCollectionView, register_view::RegisterView, set_view::SetView, @@ -179,6 +179,13 @@ impl BundleInInbox { } } +// The number of timestamp in a bucket +// The `TimestampedBundleInInbox` type contains 4 cryptohashes, 1 blockheight +// an index, two enums and the ChannelName. Only the ChannelName has an unbounded +// size but we can expect the size to be reasonably small, so a total size of 100 +// seems reasonable for the storing of the data. +const TIMESTAMPBUNDLE_BUCKET_SIZE: usize = 100; + /// A view accessing the state of a chain. #[derive(Debug, RootView, ClonableView, SimpleObject)] #[graphql(cache_control(no_cache))] @@ -208,7 +215,7 @@ where /// Mailboxes used to receive messages indexed by their origin. pub inboxes: ReentrantCollectionView>, /// A queue of unskippable bundles, with the timestamp when we added them to the inbox. - pub unskippable_bundles: QueueView, + pub unskippable_bundles: BucketQueueView, /// Unskippable bundles that have been removed but are still in the queue. pub removed_unskippable_bundles: SetView, /// Mailboxes used to send messages, indexed by their target. @@ -620,10 +627,10 @@ where } if !removed_unskippable.is_empty() { // Delete all removed bundles from the front of the unskippable queue. - let maybe_front = self.unskippable_bundles.front().await?; + let maybe_front = self.unskippable_bundles.front(); if maybe_front.is_some_and(|ts_entry| removed_unskippable.remove(&ts_entry.entry)) { - self.unskippable_bundles.delete_front(); - while let Some(ts_entry) = self.unskippable_bundles.front().await? { + self.unskippable_bundles.delete_front().await?; + while let Some(ts_entry) = self.unskippable_bundles.front() { if !removed_unskippable.remove(&ts_entry.entry) { if !self .removed_unskippable_bundles @@ -634,7 +641,7 @@ where } self.removed_unskippable_bundles.remove(&ts_entry.entry)?; } - self.unskippable_bundles.delete_front(); + self.unskippable_bundles.delete_front().await?; } } for entry in removed_unskippable { diff --git a/linera-core/src/chain_worker/state/attempted_changes.rs b/linera-core/src/chain_worker/state/attempted_changes.rs index ff86fc9b3ac..0656f0f0c46 100644 --- a/linera-core/src/chain_worker/state/attempted_changes.rs +++ b/linera-core/src/chain_worker/state/attempted_changes.rs @@ -537,7 +537,7 @@ where let chain = &mut self.state.chain; if let (Some(epoch), Some(entry)) = ( chain.execution_state.system.epoch.get(), - chain.unskippable_bundles.front().await?, + chain.unskippable_bundles.front(), ) { let ownership = chain.execution_state.system.ownership.get(); let elapsed = self diff --git a/linera-views/src/views/bucket_queue_view.rs b/linera-views/src/views/bucket_queue_view.rs index 90d8e677f19..a03916c9faa 100644 --- a/linera-views/src/views/bucket_queue_view.rs +++ b/linera-views/src/views/bucket_queue_view.rs @@ -93,7 +93,7 @@ impl Cursor { } } -#[derive(Clone)] +#[derive(Clone, Debug)] enum Bucket { Loaded { data: Vec }, NotLoaded { length: usize }, @@ -127,6 +127,7 @@ fn stored_indices(stored_data: &VecDeque<(usize, Bucket)>, position: usize /// The size `N` has to be chosen by taking into account the size of the type `T` /// and the basic size of a block. For example a total size of 100bytes to 10KB /// seems adequate. +#[derive(Debug)] pub struct BucketQueueView { context: C, /// The buckets of stored data. If missing, then it has not been loaded. The first index is always loaded.