Skip to content

Commit 3b46f4e

Browse files
Used HashedMapView for the stream_events_count. (#4660)
## Motivation For unclear reasons, the `stream_event_counts` of `MapView` is not using memoization. ## Proposal Use `HashedMapView`. ## Test Plan The CI. ## Release Plan This is a significant breaking change for TestNet/DevNet. ## Links None.
1 parent 3ffb961 commit 3b46f4e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

linera-execution/src/execution.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ use std::{collections::BTreeMap, vec};
66
use futures::{FutureExt, StreamExt};
77
use linera_base::{
88
data_types::{BlobContent, BlockHeight, StreamUpdate},
9-
identifiers::{AccountOwner, BlobId, StreamId},
9+
identifiers::{AccountOwner, BlobId},
1010
time::Instant,
1111
};
1212
use linera_views::{
1313
context::Context,
1414
key_value_store_view::KeyValueStoreView,
15-
map_view::MapView,
1615
reentrant_collection_view::HashedReentrantCollectionView,
1716
views::{ClonableView, ReplaceContext, View},
1817
};
@@ -43,8 +42,6 @@ pub struct ExecutionStateView<C> {
4342
pub system: SystemExecutionStateView<C>,
4443
/// User applications.
4544
pub users: HashedReentrantCollectionView<C, ApplicationId, KeyValueStoreView<C>>,
46-
/// The number of events in the streams that this chain is writing to.
47-
pub stream_event_counts: MapView<C, StreamId, u32>,
4845
}
4946

5047
impl<C: Context, C2: Context> ReplaceContext<C2> for ExecutionStateView<C> {
@@ -57,7 +54,6 @@ impl<C: Context, C2: Context> ReplaceContext<C2> for ExecutionStateView<C> {
5754
ExecutionStateView {
5855
system: self.system.with_context(ctx.clone()).await,
5956
users: self.users.with_context(ctx.clone()).await,
60-
stream_event_counts: self.stream_event_counts.with_context(ctx.clone()).await,
6157
}
6258
}
6359
}

linera-execution/src/execution_state_actor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ where
488488
} => {
489489
let count = self
490490
.state
491+
.system
491492
.stream_event_counts
492493
.get_mut_or_default(&stream_id)
493494
.await?;

linera-execution/src/system.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ pub struct SystemExecutionStateView<C> {
8888
pub used_blobs: HashedSetView<C, BlobId>,
8989
/// The event stream subscriptions of applications on this chain.
9090
pub event_subscriptions: HashedMapView<C, (ChainId, StreamId), EventSubscriptions>,
91+
/// The number of events in the streams that this chain is writing to.
92+
pub stream_event_counts: HashedMapView<C, StreamId, u32>,
9193
}
9294

9395
impl<C: Context, C2: Context> ReplaceContext<C2> for SystemExecutionStateView<C> {
@@ -110,6 +112,7 @@ impl<C: Context, C2: Context> ReplaceContext<C2> for SystemExecutionStateView<C>
110112
application_permissions: self.application_permissions.with_context(ctx.clone()).await,
111113
used_blobs: self.used_blobs.with_context(ctx.clone()).await,
112114
event_subscriptions: self.event_subscriptions.with_context(ctx.clone()).await,
115+
stream_event_counts: self.stream_event_counts.with_context(ctx.clone()).await,
113116
}
114117
}
115118
}

linera-sdk/src/test/chain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ impl ActiveChain {
341341
.await
342342
.expect("Failed to query chain state view")
343343
.execution_state
344+
.system
344345
.stream_event_counts
345346
.get(&stream_id)
346347
.await

0 commit comments

Comments
 (0)