Skip to content

Commit

Permalink
Make the chain manager a View. (linera-io#3135)
Browse files Browse the repository at this point in the history
## Motivation

Currently the chain manager is serialized as a whole and stored in a
`RegisterView` in the chain state view. Since it contains blobs it can
be very large, and the blobs are not needed every time the chain manager
is loaded.

## Proposal

Make the chain manager a `View`, and put the blobs in a `MapView`.

## Test Plan

This doesn't change any logic, so CI should catch regressions. (In fact,
it already did: linera-io#3133)

## Release Plan

- Nothing to do / These changes follow the usual release cycle.

## Links

- In preparation for:
linera-io#3048
- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
  • Loading branch information
afck authored Jan 15, 2025
1 parent 3262d88 commit 84ff425
Show file tree
Hide file tree
Showing 14 changed files with 369 additions and 241 deletions.
12 changes: 6 additions & 6 deletions linera-chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
pub tip_state: RegisterView<C, ChainTipState>,

/// Consensus state.
pub manager: RegisterView<C, ChainManager>,
pub manager: ChainManager<C>,

/// Hashes of all certified blocks for this sender.
/// This ends with `block_hash` and has length `usize::from(next_block_height)`.
Expand Down Expand Up @@ -381,7 +381,7 @@ where

/// Returns true if there are no more outgoing messages in flight up to the given
/// block height.
pub fn all_messages_delivered_up_to(&mut self, height: BlockHeight) -> bool {
pub fn all_messages_delivered_up_to(&self, height: BlockHeight) -> bool {
tracing::debug!(
"Messages left in {:.8}'s outbox: {:?}",
self.chain_id(),
Expand Down Expand Up @@ -571,8 +571,8 @@ where
self.execution_state_hash.set(Some(hash));
let maybe_committee = self.execution_state.system.current_committee().into_iter();
// Last, reset the consensus state based on the current ownership.
self.manager.get_mut().reset(
self.execution_state.system.ownership.get(),
self.manager.reset(
self.execution_state.system.ownership.get().clone(),
BlockHeight(0),
local_time,
maybe_committee.flat_map(|(_, committee)| committee.keys_and_weights()),
Expand Down Expand Up @@ -873,8 +873,8 @@ where
self.execution_state_hash.set(Some(state_hash));
// Last, reset the consensus state based on the current ownership.
let maybe_committee = self.execution_state.system.current_committee().into_iter();
self.manager.get_mut().reset(
self.execution_state.system.ownership.get(),
self.manager.reset(
self.execution_state.system.ownership.get().clone(),
block.height.try_add_one()?,
local_time,
maybe_committee.flat_map(|(_, committee)| committee.keys_and_weights()),
Expand Down
Loading

0 comments on commit 84ff425

Please sign in to comment.